杭电acm 2027 原题地址http://acm.hdu.edu.cn/showproblem.php?pid=2027
#include<stdio.h>intmain(){chara[100];ints1,s2,s3,s4,s5,n,i;scanf("%d",&n);s1=0,s2=0,...
#include<stdio.h>
int main()
{
char a[100];
int s1,s2,s3,s4,s5,n,i;
scanf("%d",&n);
s1=0,s2=0,s3=0,s4=0,s5=0;
getchar();
while(n--)
{
gets(a);
for(i=0;i<100&&a[i]!='\n';i++)
{
if(a[i]=='a')
s1++;
if(a[i]=='e')
s2++;
if(a[i]=='i')
s3++;
if(a[i]=='o')
s4++;
if(a[i]=='u')
s5++;
}
printf("a:%d\n",s1);
printf("e:%d\n",s2);
printf("i:%d\n",s3);
printf("o:%d\n",s4);
printf("u:%d\n",s5);
if(n)
printf("\n");
s1=0,s2=0,s3=0,s4=0,s5=0;
}
return 0;
} 展开
int main()
{
char a[100];
int s1,s2,s3,s4,s5,n,i;
scanf("%d",&n);
s1=0,s2=0,s3=0,s4=0,s5=0;
getchar();
while(n--)
{
gets(a);
for(i=0;i<100&&a[i]!='\n';i++)
{
if(a[i]=='a')
s1++;
if(a[i]=='e')
s2++;
if(a[i]=='i')
s3++;
if(a[i]=='o')
s4++;
if(a[i]=='u')
s5++;
}
printf("a:%d\n",s1);
printf("e:%d\n",s2);
printf("i:%d\n",s3);
printf("o:%d\n",s4);
printf("u:%d\n",s5);
if(n)
printf("\n");
s1=0,s2=0,s3=0,s4=0,s5=0;
}
return 0;
} 展开
2个回答
展开全部
下面是AC过了的代码。你的代码有点细节毛病,自己看一下改改就可以了
#include <string.h>
#include<stdio.h>
int main()
{
char a[100];
int s1,s2,s3,s4,s5,n,i,j;
scanf("%d",&n);
getchar();
while(n--)
{
s1=s2=s3=s4=s5=0;
gets(a);
j = strlen(a);
for(i=0;i<j;i++)
{
if(a[i]=='a')
s1++;
if(a[i]=='e')
s2++;
if(a[i]=='i')
s3++;
if(a[i]=='o')
s4++;
if(a[i]=='u')
s5++;
}
printf("a:%d\n",s1);
printf("e:%d\n",s2);
printf("i:%d\n",s3);
printf("o:%d\n",s4);
printf("u:%d\n",s5);
if(n)
printf("\n");
}
return 0;
}
#include <string.h>
#include<stdio.h>
int main()
{
char a[100];
int s1,s2,s3,s4,s5,n,i,j;
scanf("%d",&n);
getchar();
while(n--)
{
s1=s2=s3=s4=s5=0;
gets(a);
j = strlen(a);
for(i=0;i<j;i++)
{
if(a[i]=='a')
s1++;
if(a[i]=='e')
s2++;
if(a[i]=='i')
s3++;
if(a[i]=='o')
s4++;
if(a[i]=='u')
s5++;
}
printf("a:%d\n",s1);
printf("e:%d\n",s2);
printf("i:%d\n",s3);
printf("o:%d\n",s4);
printf("u:%d\n",s5);
if(n)
printf("\n");
}
return 0;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询