c language practice 17-- input line of characters, respectively, the statistics of the English alphabet, spaces, numbers and other characters of the number of

#include <stdio.h> 
#include <stdlib.h>
 / * Title: an input line of characters, respectively, the statistics of the number of English letters, spaces, numbers and other characters wherein * / 
int main () { 
    System ( " Color 1F " );   // set the display frame for the blue white 
    System ( " MODE CON Lines cols = 80 = 30 " );   // fixed display frame size 
    / * *************** ************************** program body parting line (top) ***************************************************** ******* * / 
    int L, I, N1, N2, N3, N4;
     char S [ 100 ];
     the while ( . 1 ) { 
    N1 = 0 ; 
    N2= 0 ; 
    N3 = 0 ; 
    N4 = 0 ; 
    the printf ( " Enter a line of characters (carriage return): \ n- " );
     for (I = 0 ; I < 100 ; I ++ ) { 
        Scanf ( " % C " , & S [I]);
         IF (S [I] == ' \ n- ' )
             BREAK ; 
    } 
    L = I;
     for (I = 0 ; I <L; I ++ )
         IF (S [I]> = ' A'&&s[i]<='Z')
            n1++;
        else if(s[i]>='a'&&s[i]<='z')
            n1++;
        else if(s[i]==' ')
            n2++;
            else if(s[i]>='0'&&s[i]<='9')
                n3++;
                else
                    n4++ ; 
    printf ( " This line characters in the English character has a [% d] - [% d] spaces have a - have digital [% d] a - the other characters have] a [% d \ n ----- -------------------------------------------------- ----------------------- \ n- " , N1, N2, N3, N4); 
} 
    / * *********** ****************************** program body parting line (bottom) ************* ************* * / 
    return  0 ; 
}

 

Guess you like

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