diff --git a/字符类型统计 b/字符类型统计 new file mode 100644 index 0000000..4933c0c --- /dev/null +++ b/字符类型统计 @@ -0,0 +1,24 @@ +#include +#include +int main() +{ + char str[100]; + int n, a = 0, b = 0, c = 0, d = 0, e = 0; + gets(str); + n = strlen(str); + for(int i = 0; i < n; i ++) + { + if(str[i] >='A' && str[i] <= 'Z') + a ++; + else if(str[i] >= 'a' && str[i] <= 'z') + b ++; + else if(str[i] >= '0' && str[i] <= '9') + c ++; + else if(str[i] == ' ') + d ++; + else + e ++; + } + printf("capital letters:%d\nsmall letters:%d\nblank spaces:%d\nnumbers:%d\nother:%d", a, b, d, c, e); + return 0; +} \ No newline at end of file