C语言数组的问题
有一篇文章,共有3行文字,每行有80个字符,要求分别统计出其中英文大写字母、小写字母、数字、空格以及其他字符的个数求赐教函数要怎么写
#include<stdio.h> #include<ctype.h> int main() { char *s[]={"中国 abc","12345 ABCDE","!@#"};//初始化文章,内容自己改~ char **p=s; int Chinese[3]={0},English[3]={0},Big[3]={0},Small[3]={0},Number[3]={0},Space[3]={0},Other[3]={0}; int i,j; for (i=0;i<3;i++) for (j=0;p[i][j]!='\0';j++) { if (p[i][j]<0)Chinese[i]++; else if (isalpha(p[i][j])!=0&&p[i][j]>=0)English[i]++; if (islower(p[i][j])!=0&&p[i][j]>=0)Small[i]++; else if (isupper(p[i][j])!=0&&p[i][j]>=0)Big[i]++; else if (isdigit(p[i][j])!=0&&p[i][j]>=0)Number[i]++; else if (p[i][j]==' '&&p[i][j]>=0)Space[i]++; else if (p[i][j]>=0)Other[i]++; } for (i=0;i<3;i++) { printf("Line_%d:\n",i+1); printf("Chinese is:%d\n",Chinese[i]/2);//一个汉字占用两个字节,所以个数要/2。 printf("English is:%d\n",English[i]); printf("Big is:%d\n",Big[i]); printf("Small is:%d\n",Small[i]); printf("Number is:%d\n",Number[i]); printf("Space is:%d\n",Space[i]); printf("Other is:%d\n",Other[i]); printf("\n\n"); } }