|
发表于 2021-11-20 11:36:45
|
显示全部楼层
本帖最后由 jhq999 于 2021-11-20 11:39 编辑
- #include <stdio.h>
- int main(void)
- {
- int num[10]={0},blank[3]={0},others=0,i=0,j=0;
- char strch[256]={0};
- while(1)
- {
- scanf("%[^\n]",strch);
- fflush(stdin);
- if((strch[0]=='e'&&strch[1]=='x')&&(strch[2]=='i'&&strch[3]=='t'))break;
- i=0;
- while(strch[i])
- {
- switch(strch[i])
- {
- case '\t':
- blank[1]++;
- break;
- case ' ':
- blank[2]++;
- break;
- default:
- if('0'<=strch[i]&&'9'>=strch[i])
- num[strch[i]-'0']++;
- else
- others++;
- break;
- }
- i++;
- }
- blank[0]++;
- }
- printf("\\n is:%d,\\t is: %d,space is: %d\n",blank[0],blank[1],blank[2]);
- for ( i = 0; i < 10; i++)
- {
- printf("%d is:%d\n",i,num[i]);
- }
- printf("others is:%d",others);
- return 0;
- }
复制代码- gh67t67t67t 9h98jiojj oko0kko
- jiojpu787867564vbbh uhu7689098967809
- 6876y86
- 8090jhygty6t
- exit
- \n is:4,\t is: 3,space is: 6
- 0 is:5
- 1 is:0
- 2 is:0
- 3 is:0
- 4 is:1
- 5 is:1
- 6 is:11
- 7 is:9
- 8 is:9
- 9 is:7
- others is:38
复制代码 |
|