c语言杭电acm统计元音总是答案错误是为什么?
http://acm.hdu.edu.cn/showproblem.php?pid=2027#include<stdio.h>#include<string.h>intm...
http://acm.hdu.edu.cn/showproblem.php?pid=2027
#include<stdio.h>
#include<string.h>
int main()
{
char s[1000];int n,A,U,O,I,E,len;
scanf("%d",&n);
while(n--)
{ getchar();
gets(s);
len=strlen(s);
A=0;U=0;O=0;E=0;I=0;
for(int i=0;i<len;i++)
{
if(s[i]=='A'||s[i]=='a')
A++;
if(s[i]=='O'||s[i]=='o')
O++;
if(s[i]=='I'||s[i]=='i')
I++;
if(s[i]=='e'||s[i]=='E')
E++;
if(s[i]=='u'||s[i]=='U')
U++;
}
printf("a:%d\n",A);
printf("e:%d\n",E);
printf("i:%d\n",I);
printf("o:%d\n",O);
printf("u:%d",U);
if(n!=0)
printf("\n\n");
else
printf("\n");
}
return 0;
} 展开
#include<stdio.h>
#include<string.h>
int main()
{
char s[1000];int n,A,U,O,I,E,len;
scanf("%d",&n);
while(n--)
{ getchar();
gets(s);
len=strlen(s);
A=0;U=0;O=0;E=0;I=0;
for(int i=0;i<len;i++)
{
if(s[i]=='A'||s[i]=='a')
A++;
if(s[i]=='O'||s[i]=='o')
O++;
if(s[i]=='I'||s[i]=='i')
I++;
if(s[i]=='e'||s[i]=='E')
E++;
if(s[i]=='u'||s[i]=='U')
U++;
}
printf("a:%d\n",A);
printf("e:%d\n",E);
printf("i:%d\n",I);
printf("o:%d\n",O);
printf("u:%d",U);
if(n!=0)
printf("\n\n");
else
printf("\n");
}
return 0;
} 展开
3个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询