回复 楼主 a447340229
#include<stdio.h>
main()
{
int i = 0, a = 0, b = 0, c = 0, d = 0, j;
char n, m[512];
printf("please enter :");
while ((n = getchar()) != '\n')
{
m[i] = n;
if (((m[i] >= 'a')&&(m[i] <= 'z'))||((m[i] >= 'A')&&(m[i] <= 'Z')))
a++;
else if ((m[i] >= '0')&&(m[i] <= '9'))
b++;
else if (m[i] == ' ')
// ' '之间有一个空格
c++;
else
d++;
i++;
}
printf("字母有:%d个\n数字有:%d个\n空格有:%d个\n其他字符有:%d个\n", a, b, c, d);
return 0;
}
[
本帖最后由 zhaobings 于 2012-12-25 09:54 编辑 ]