🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
>[info]计算一行字符串中字母,空格,数字,其他类型的字符长度 ~~~C #include <stdio.h> int main() { char c; int clength=0,slength=0,nlength=0,olength=0; printf("input some word:\n"); while((c=getchar())!='\n') { if((c>='a' && c<='z') || (c>='A' && c<='Z')) clength++; else if(c>='0' && c<='9') nlength++; else if(c==' ') slength++; else olength++; } printf("字母长%d,空格长%d,数字长%d,其他长%d", clength, slength, nlength, olength); return 0; } ~~~