找出各个字母,数字等的个数
程序代码:
#include"stdio.h" #include"string.h" #define N 100 main() { int i,j,num=0,upr=0,lwr=0,space=0,other=0; char a[3][N]; gets(a); for(i=0;i<=2;i++) for(j=0;j<=strlen(a);j++) { if(a[i][j]>=0&&a[i][j]<=9) num++; else if(a[i][j]>=65&&a[i][j]<=90) upr++; else if(a[i][j]>=97&&a[i][j]<=122) lwr++; else if(a[i][j]==" ") space++; else other++; } printf("%3d%3d%3d%3d%3d%3d",num,upr,lwr,space,other); }