#include <stdio.h>
int main(int argc,int *argv[])
{
char c;
int char_count = 0, num_count = 0, space_count = 0, other_count = 0;
printf("please input chars:\n");
while ((c=getchar()) != '\n')
{
if (c >= 'A' && c <= 'Z' || c >= 'a' && c <= 'z')
{
char_count ++;
}
else if (c >='0' && c <='9')
{
num_count ++;
}
else if (c == ' ')
{
space_count ++;
}
else
{
other_count ++;
}
}
printf("the char count:%d ,the num count:%d ,the space count:%d ,ohter char count :%d\n",
char_count,num_count,space_count,other_count);
system("pause");
return 0;
}
|