写一个程序,统计字符串的大写字母个数、小写字母个数、数字个数和其它字符个数。用函数func实现功能,在main中,至少使用10个字符串对函数进行测试。

#include #include int func3(char*m,int leng) { int i; int M[5]={0}; for(i=0; i=48&&m[i]<=57) M[2]++; if(m[i]>=65&&m[i]<=90) M[0]++; if(m[i]>=97&&m[i]<=122) M[1]++; /*if(!((m[i]>=48&&m[i]<=57)&&(m[i]>=65&&m[i]<=90)&&(m[i]>=97&&m[i]<=122)))*/ M[3]++; } for(i=0; i<4; i++) { if(i==2) printf("digits:%d",M[i]); if(i==0) printf("upper:%d",M[i]); if(i==1) printf("lomer:%d",M[i]); if(i==3) printf("other:%d",M[i]); } } int main() { int leng ,j; char *m; m=(char *)malloc(sizeof(char)*20); gets(m); leng=strlen(m); j=func3(m,leng); printf("%d\n",j); return 0; }

【写一个程序,统计字符串的大写字母个数、小写字母个数、数字个数和其它字符个数。用函数func实现功能,在main中,至少使用10个字符串对函数进行测试。】写一个程序,统计字符串的大写字母个数、小写字母个数、数字个数和其它字符个数。用函数func实现功能,在main中,至少使用10个字符串对函数进行测试。
文章图片

    推荐阅读