tags: c
#include <stdio.h>
int main()
{
int a,b,c,d,ch;
a=b=c=d=0;// The counter is initialized to 0.
while((ch=getchar())!='\n')// Cycle read characters to the end of the wrap.
{
if(ch>='0' && ch<='9')//number
a++;
else if((ch>='a' && ch<='z')||(ch>='A' && ch<='Z'))//letter
b++;
else if(ch==' ')// space
c++;
else //other
d++;
}
printf("%d %d %d %d\n", a,b,c,d);// Output result.
return 0;
}
C language code: operation result:...
First, the title is brief Enter a line of characters, count the number of English letters, spaces, numbers, and other characters, respectively. Second, the topic analysis Analysis of Algorithms: Use l...
Topic description Enter a line of characters, statistics to the number of English letters, spaces, numbers, and other characters, respectively. Input description: Enter a line of strings, you can have...
Enter a line of characters, statistics to the number of English letters, spaces, numbers, and other characters, respectively. The key to this question is the format of the output:...
Program analysis: Use the While statement, the condition is not the input character is not '\ n'. code show as below: The first: operation result: Second: operation result:...
Program Book Algorithm - JS Edition Enter a line of characters, count the number of English letters, spaces, numbers, and other characters, respectively. Source console...
When statistics, the number of types, as long as the specific type of heavy character is removed, the original length - the remaining length = a particular type of number. Regular expressions can quic...
Beginner C language, if there is a mistake, hope to correct....