#include <stdio.h>
int main() {
char *s;
char c;
int dCount = 0, xCount = 0, numCount = 0, oCount = 0;
printf("请输入字符串,以回车结束: \n");
//scanf("%s", s);
while((c = getchar()) != '\n')
{
//c = getchar();
if (c <= 'Z' && c >= 'A')
{
dCount += 1;
}
else if (c <= 'z' && c >= 'a')
{
xCount += 1;
}
else if (c <= '9' && c >= '0')
{
numCount += 1;
}
else
{
oCount += 1;
}
}
printf("%4d %4d %4d %4d\n", dCount, xCount, numCount, oCount);
} |
|