题解 | #统计字符#
统计字符
https://www.nowcoder.com/practice/539054b4c33b4776bc350155f7abd8f5
#include <stdio.h> int main() { int a, b,en,space,num,el; char str1[1000]; space=0; num=0; en=0; el=0; gets(str1); a=strlen(str1); for(b=0;b<a;b++) { if(islower(str1[b])||isupper(str1[b])) en++; else if(isdigit(str1[b])) num++; else if(str1[b]==' ') space++; else el++; } printf("%d\n",en); printf("%d\n",space); printf("%d\n",num); printf("%d",el); return 0; }