/* Note:Your choice is C IDE */ #include "stdio.h" #include"string.h" int zimu(char line[100]); int kongge(char line[100]); int shuzi(char line[100]); void main() { char line[100]; puts("please input a line:"); gets(line); puts(line); printf("the all char is %d\n",strlen(line)); printf("the zimu is %d\n",zimu(line)); printf("the kongge is %d\n",kongge(line)); printf("the shuzi is %d\n",shuzi(line)); printf("the else is %d\n",strlen(line)-zimu(line)-kongge(line)-shuzi(line)); } int zimu(char line[100]) { int i=0; int u=0; for(i=0;i<100;i++) if((line[i]<=122&&line[i]>=97)||(line[i]<=90&&line[i]>=65)) u++; return u;} int kongge(char line[100]) { int i=0; int u=0; for(i=0;i<100;i++) if(line[i]==' ') u++; return u;} int shuzi(char line[100]) { int i=0; int u=0; for(i=0;i<100;i++) { if(line[i]>=48&&line[i]<=57) u++; } return u;}
week 10 字符串
最新推荐文章于 2022-04-02 14:54:57 发布