💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
>[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; } ~~~