简单的C题解 | #统计字符#
统计字符
http://www.nowcoder.com/practice/539054b4c33b4776bc350155f7abd8f5
#include <stdio.h> #include <string.h> int main(void) { char input[1000]; int Nnum = 0,Enum = 0,Knum = 0,Onum = 0; gets(input); { for(int i=0;i<strlen(input);i++) { if(input[i] >= '0' && input[i] <= '9') Nnum++; else if((input[i] >= 'a' && input[i] <= 'z') || (input[i] >= 'A' && input[i] <= 'Z')) Enum++; else if(input[i] == ' ') Knum++; else Onum++; } printf("%i\n",Enum); printf("%i\n",Knum); printf("%i\n",Nnum); printf("%i\n",Onum); return 0; } }