c:求字母什么的的个数(个人感觉这个很实用)

mac2024-07-08  52

#include<stdio.h> main() { char c; int a=0,b=0,d=0; while((c=getchar())!='\n') { if(c<='Z'&&c>='A'||c<='z'&&c>='a') a++; else if(c>='0'&&c<='9') b++; else d++; } printf("字母有%d个\n数字有%d个\n其他有%d",a,b,d); }
最新回复(0)