|
发表于 2022-1-3 15:34:21
From FishC Mobile
|
显示全部楼层
本楼为最佳答案
- #include <stdio.h>
- #include <ctype.h>
- int main(){
- char c;
- int digit = 0, lower = 0, upper = 0, newline = 0, tab = 0, space = 0, other = 0;
- while((c = getchar()) != EOF){
- if(isdigit(c)) digit++;
- else if(islower(c)) lower++;
- else if(isupper(c)) upper++;
- else if(c == '\n') newline++;
- else if(c == '\t') tab++;
- else if(c == ' ') space++;
- else other++;
- }
-
- printf("digit = %d\nlower = %d\nupper = %d\nnewline = %d\ntab = %d\nspace = %d\nother = %d", digit, lower, upper, newline, tab, space, other);
-
- return 0;
- }
复制代码 |
|