输入3*8的一个数组,要求分别统计出其中的英文大写字母,小写字母,数字,空格以及其他字符的个数...
#include <stdio.h>#include <string.h>#include<conio.h>void main(){ char str[3][8];int i,j,big,small,num,space,other;big=small=num=space=other=0;printf("enter 3 rows and 8 lines characters:\n");for(i=0;i<3;i++)gets(str[i]);for(i=0;i<3;i++)for(j=0;j<strlen(str[i])+1;j++)if(str[i][j]>='A'&&str[i][j]<='Z')big++;else if(str[i][j]>='a'&&str[i][j]<='z')small++;else if(str[i][j]>='0'&&str[i][j]<='9')num++;else if(str[i][j]==' ')space++;else other++;printf("big=%3d,small=%3d,num=%3d,space=%3d,other=%3d", big,small,num,space,other);//getch();} |