|
- //實(shí)現(xiàn)類(lèi)似于word里面統(tǒng)計(jì)的功能
- //3*80
- //統(tǒng)計(jì)大寫(xiě)字母、小寫(xiě)字母、數(shù)字、空格及其他字符數(shù)
- #include<stdio.h>
- void main()
- {int i,j;
- int c=0,l=0,n=0,s=0,o=0;
- char a[3][5];//類(lèi)型指定錯(cuò)了
- for(i=0;i<3;i++)//首先輸入30個(gè)字符
- {
- for(j=0;j<5;j++)
- {
- scanf("%c",&a[i][j]);//輸入的時(shí)候不要有空格,因?yàn)榭崭窬褪且粋(gè)字符
- }
- }
- for(i=0;i<3;i++)
- {
- for(j=0;j<5;j++)
- {
- if(a[i][j]>=65&&a[i][j]<=90)
- {
- c+=1;
- }
- else if(a[i][j]>=97&&a[i][j]<=122)
- {
- l+=1;
- }
- else if(a[i][j]==32)
- {
- s+=1;
- }
- else if(a[i][j]>=48&&a[i][j]<=57)
- {
- n+=1;
- }
- else
- o+=1;
- }
- }
- printf("capital=%d\n",c);
- printf("lower=%d\n",l);
- printf("number=%d\n",n);
- printf("space=%d\n",s);
- printf("other=%d\n",o);
- printf("\n");
- }
復(fù)制代碼
|
|