• 回答数

    7

  • 浏览数

    329

崽崽龙08
首页 > 英语培训 > 统计英文字母个数

7个回答 默认排序
  • 默认排序
  • 按时间排序

四十一度灰

已采纳

#include void main(){ int letter, space, number, other; char ch; letter = space = number = other = 0; while((ch = getchar()) != '\n') if('A' <= ch && ch <= 'Z' || 'a' <= ch && ch <= 'z') letter++; else if(ch == ' ') space++; else if('0' <= ch && ch <= '9') number++; else other++; printf("letter:%d\n", letter); printf("space:%d\n", space); printf("number:%d\n", number); printf("other:%d\n", other);}

统计英文字母个数

282 评论(10)

梧桐无羽

#include#includeint main(){ char a[120],j; int i,n; while(gets(a)!=NULL) { for(i=0;i='A'&&a[i]<='Z')) a[i]+=32; } for(j='a';j<='z';j++) { n=0; for(i=0;i

178 评论(10)

傲慢的猩猩

#include int main(){    int alpha,digit,others;    char c;    for(alpha=digit=others=0;(c=getchar())!='\n';)    {        if(c>='a'&&c<='z'||c>='A'&&c<='Z')            alpha++;        else if(c>='0'&&c<='9')            digit++;        else            others++;    }    printf("%d %d %d\n",alpha,digit,others);    return 0;}

237 评论(8)

shampooxia

#include

int main()

{char s[200];

int i,n=0;

gets(s);

for(i=0;s[i];i++)

if(s[i]>='A'&&s[i]<='Z'||s[i]>='a'&&s[i]<='z')n++;

printf("%d\n",n);

getch();

return 0;

}

88 评论(10)

蓝晶灵儿

#includeintmain(){charc[50];inti,el=0,sp=0,nu=0,other=0;gets(c);//输入字符串for(i=0;i='a'&&c[i]<='z')||(c[i]>='a'&&c[i]<='z'))el++;elseif(c[i]>='0'&&c[i]<='9')nu++;elseif(c[i]=='')sp++;elseother++;}printf("英文字母个数=%d\n数字个数=%d\n空格字数=%d\n其他字符个数=%d\n",el,nu,sp,other);return0;}已经测试过了,测试结果如下,有问题可以继续追问。

120 评论(11)

优优妈妈0509

吧侧妃hill空

83 评论(8)

jingbin657501

运行样例:

305 评论(12)

相关问答