题解 | #统计字符#
统计字符
https://www.nowcoder.com/practice/539054b4c33b4776bc350155f7abd8f5
#include <stdio.h> int main() { char s[1001]={0}; gets(s); int i=0; int y=0; int k=0; int n=0; int q=0; while(s[i]!='\0') { if(s[i]>='a'&&s[i]<='z') y++; else if(s[i]==' ') k++; else if(s[i]>='0' && s[i]<='9') n++; else q++; i++; } printf("%d\n%d\n%d\n%d",y,k,n,q); return 0; }