#include <stdio.h>
int main() {
char s[1000];
char *p = s;
printf("Input String:");
fgets(s, sizeof(s), stdin);
int len[5] = {0,0,0,0,0};
while (*p++) {
if (*p>='A' && *p<='Z') len[0] ++;
else if (*p>='a' && *p <='z') len[1] ++;
else if (*p==0x20) len[2] ++;
else if (*p>='1' && *p <='9') len[3] ++;
else len[4] ++;
}
printf("大写:%d, 小写:%d, 空格:%d, 数字:%d, 其他:%d\n", len[0],len[1],len[2],len[3],len[4]);
return 0;
}
温馨提示:答案为网友推荐,仅供参考