#include <stdio.h>
int main(int argc,int *argv[])
{
char c;
int letter = 0, space = 0, digit = 0, other = 0;
printf("please input some characters\n");
while ((c = getchar()) != '\n')
{
if(c >= 'a' && c <='z' || c >='A' && c <='Z')
{
letter ++;
}
else if (c == ' ')
{
space ++;
}
else if(c >= '0' && c <='9')
{
digit ++;
}
else
{
other ++;
}
}
printf("the char = %d,digit = %d,space = %d,other = %d\n",letter,digit,space,other);
system("pause");
return 0;
}
|