//8.8 输入一行文字,找出其中大写字母、小写字母、空格、数字以及其他字符各有多少。 #includeint main() { int uper = 0, lower = 0, digit = 0, space = 0, other = 0, i = 0; char s[40], *p; printf("input string:n"); while ((s[i] = getchar()) != 'n') i++; p = s; while (*p != 'n') //注意此处不是‘ ’ 为字符串输入使用的结尾。 { if ((*p >= 'A') && (*p <= 'Z')) uper=uper+1; else if ((*p >= 'a') && (*p <= 'z')) lower=lower+1; else if ((*p >= '0') && (*p <= '9')) digit=digit+1; else if (*p == ' ') space=space+1; else other=other+1; p=p+1; } printf(" uper=%dn lower=%dn digit=%dn space=%dn other=%dn", uper, lower, digit, space, other); return 0; }



