c language practice 39-- insert a number to the number of columns in

#include <stdio.h> 
#include <stdlib.h>
 / * Title: If the number is exactly equal to a sum of factors in addition to its own outside, this number is called the "number of completed." Example 6 = 1 + 2 + 3 programming to identify all well finished within 1000 * / 
int main () { 
    System ( " Color 1F " );   // set the display frame for the blue white 
    System ( " MODE CON cols = 80 Lines = 30 " );   // fixed display frame size 
/ * *************************************** ** program body parting line (top) ************************************************************ * / 
int NUM, I, J, K, L; 
 int A [ 100 ];
 the while ( . 1 ) {
 char CH;
 for (I =0 ; I <= 100 ; I ++ ) { 
    the printf ( " Please output of% d of numbers or alphabetical O end input " , I + . 1 ); 
    Scanf ( " % d " , & A [I]); 
    CH = getchar () ;
     IF (CH == ' O ' )
     BREAK ; 
} 
L = I; 
the printf ( " \ n-enter the number to be inserted: " ); 
Scanf ( " % D " , & NUM);
 IF (a [ 0 ] < A [L]) {
     for (J =0;j<=i;j++)
        if(a[j]>=num){
        break;}
    for(k=l+1;k>j;k--) 
        a[k]=a[k-1];
}
else {
    for(j=0;j<=i;j++)
        if(a[j]<=num){
        break;}
    for(k=l+1;k>j;k--) 
        a[k]=a[k-1];
}        
a[j]=num;
printf("\n新的顺序为:\n");
 For (I = 0 ; I <= L; I ++ ) 
    the printf ( " % D " , A [I]); 
the printf ( " \ n------------------ -------------------------------------------------- --------- \ n- " ); 

} 

/ * ********************************* ******** program body parting line (bottom) ************************************************************ * / 
    return  0 ; 
}            

 

 

Guess you like

Origin www.cnblogs.com/gougouwang/p/11470105.html