如上
#include "stdio.h"
int main(int argc,char *argv[]){
char a,b,c,ch,i;
printf("Please enter the 10 characters...\n");
for(a=b=c=i=0;i<10;i++){
scanf(" %c",&ch);
if(ch>='a' && ch<='z' || ch>='A' && ch<='Z')
a++;
else if(ch>='0' && ch<='9')
b++;
else
c++;
}
printf("The letter: %d\nThe digit: %d\nThe other: %d\n",a,b,c);
return 0;
}
int main(int argc,char *argv[]){
char a,b,c,ch,i;
printf("Please enter the 10 characters...\n");
for(a=b=c=i=0;i<10;i++){
scanf(" %c",&ch);
if(ch>='a' && ch<='z' || ch>='A' && ch<='Z')
a++;
else if(ch>='0' && ch<='9')
b++;
else
c++;
}
printf("The letter: %d\nThe digit: %d\nThe other: %d\n",a,b,c);
return 0;
}
运行样例:
大小写字母怎么统计
追答题主你太忽悠人了吧?看看题是怎么说的:“统计英文字母的个数(包括大小写)”,那就是不分大小写只要是字母就累加,怎么又分别统计大、小写了?
温馨提示:答案为网友推荐,仅供参考
第1个回答 2018-12-31
#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;
}追问
int main()
{
int alpha,ALPHA,digit,others;
char c;
for(alpha=ALPHA=digit=others=0;(c=getchar())!='\n';)
{
if(c>='a'&&c<='z')
alpha++;
else if(c>='A'&&c<='Z')
ALPHA++;
else if(c>='0'&&c<='9')
digit++;
else
others++;
}
printf("%d %d %d %d\n",alpha,ALPHA,digit,others);
return 0;
}追问
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;
}追问
大小写字母怎么统计
追答#include <stdio.h>int main()
{
int alpha,ALPHA,digit,others;
char c;
for(alpha=ALPHA=digit=others=0;(c=getchar())!='\n';)
{
if(c>='a'&&c<='z')
alpha++;
else if(c>='A'&&c<='Z')
ALPHA++;
else if(c>='0'&&c<='9')
digit++;
else
others++;
}
printf("%d %d %d %d\n",alpha,ALPHA,digit,others);
return 0;
}追问
谢了
本回答被提问者采纳第2个回答 2018-12-31
就是觉得没什么胃口大开发开博尔看到你就懂得看到你你复古风就觉得看我怎么咳嗽买啥
第3个回答 2018-12-31
吧侧妃hill空
第4个回答 2018-12-31
吧侧妃hill空