LeeBlog

导航

HDU 2027 统计元音

  继续以水题,不过注意输出格式,还有输入时不要用fflush( stdin ),用%*c

 

代码
#include <stdio.h>
#include
<stdlib.h>
#include
<string.h>
int main ( )
{
int N,n,a,e,i,o,u,j;
char s[65];
scanf (
"%d%*c",&N );
while ( N-- )
{
a
= e = i = o = u = 0;
gets ( s );
n
= strlen ( s );
for ( j = 0; j < n; ++j )
{
if ( s[j] == 'a'|| s[j] == 'A' )
++a;
else if ( s[j] == 'e' ||s[j] == 'E' )
++e;
else if ( s[j] == 'i' ||s[j] == 'I' )
++i;
else if ( s[j] == 'o' ||s[j] == 'O' )
++o;
else if ( s[j] == 'u' ||s[j] == '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\n",u );
if ( N != 0 )
printf (
"\n" );
}
return 0;
}

 

posted on 2011-01-26 13:35  LeeBlog  阅读(222)  评论(0编辑  收藏  举报