hdu 2027
来源:互联网 发布:买一个域名要多少钱 编辑:程序博客网 时间:2024/05/01 05:08
//字符串有待加强!!!
#include<iostream>
#include<cstring>
using namespace std;
void main()
{
char s[1000];
int n,n1,n2,n3,n4,n5,i;
cin>>n;
while(n--)
{
n1=0,n2=0,n3=0,n4=0,n5=0;
gets(s);
int t=strlen(s);
for(i=0;i<t;i++)
{
if(s[i]=='a')
{
n1++;break;
}
else if(s[i]=='e')
{
n2++;break;
}
else if(s[i]=='i')
{
n3++;break;
}
else if(s[i]=='o')
{
n4++;break;
}
else if(s[i]=='u')
{
n5++;break;
}
}
cout<<"a"<<":"<<n1<<endl;
cout<<"e"<<":"<<n2<<endl;
cout<<"i"<<":"<<n3<<endl;
cout<<"o"<<":"<<n4<<endl;
cout<<"u"<<":"<<n5<<endl;
}
}
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
char s[1000];
int n,n1,n2,n3,n4,n5,i;
cin>>n;
getchar();//吸收空格!!!!
while(n--)
{
n1=0,n2=0,n3=0,n4=0,n5=0;
gets(s);
int t=strlen(s);
for(i=0;i<t;i++)
{
if(s[i]=='a')
{
n1++;
}
else if(s[i]=='e')
{
n2++;
}
else if(s[i]=='i')
{
n3++;
}
else if(s[i]=='o')
{
n4++;
}
else if(s[i]=='u')
{
n5++;
}
}
cout<<"a"<<":"<<n1<<endl;
cout<<"e"<<":"<<n2<<endl;
cout<<"i"<<":"<<n3<<endl;
cout<<"o"<<":"<<n4<<endl;
cout<<"u"<<":"<<n5<<endl;
if(n!=0)
cout<<endl;
}
return 0;
}
/*#include <stdio.h>
#include <string>
char a[105];
int main()
{
int n,len,i,j,k,b[5];
char word1[5]={'a','e','i','o','u'},word2[5]={'A','E','I','O','U'};
while(scanf("%d",&n)!=EOF && n)
{
getchar();
for(k=0;k<n;k++)
{
len=0;
gets(a);
len=strlen(a);
memset(b,0,sizeof(b));
for(i=0;i<len;i++)
{
for(j=0;j<5;j++)
{
if(a[i]==word1[j] || a[i]==word2[j])
{
b[j]++;
break;
}
}
}
for(i=0;i<5;i++)
{
printf("%c",word1[i]);
printf(":");
printf("%d\n",b[i]);
}
if(k!=n-1)
printf("\n");
}
}
return 0;
}
多次提交说明,该题可以忽略元音字母为大写字母的情况。
这虽然是一道典型的水题。但是对c/c++的输入输出长见识了,getchar()的作用值得研究,如果没有它,这题就暂时拿它没办法了。。。
可以输入回车键: while((a[len]=getchar())!=EOF) len++;
统计元音
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<time.h>
int T , sign[200] , hash[5]={'a' , 'e' , 'i' , 'o' , 'u'};
char str[105];
int main()
{
scanf( "%d%*" ,&T );
while( T-- )
{
memset( sign , 0 ,sizeof(sign) );
gets( str );
int len = strlen ( str );
for( int i=0 ; i<len ; ++i )
sign[str[i]]++;
for( int i=0 ;i< 5;++i )
printf( "%c:%d\n" ,hash[i],sign[hash[i]]);
if( T > 0)
puts( "" );
}
return 0;
}
*/
- hdu 2027
- hdu 2027
- HDU-2027
- HDU 2027
- HDU--2027
- HDU-2027
- hdu 2027
- HDU 2027
- hdu 2027 统计元音
- HDU 2027 统计元音
- hdu——2027
- HDU 2027 统计元音
- Hdu 2027 - 统计元音
- HDU 2027 统计元音
- HDU 2027 统计元音
- HDU 2027 统计元音
- HDU 2027 统计元音
- HDU 2027 - 统计元音
- 实用算法实践-第 4 篇散列表
- Linux 中的 VFS 文件系统机制
- hdu2091
- flash绘图API :蚂蚁线
- 16. 26. 4. 刷新图片-古老的办法 Flush an image
- hdu 2027
- hdu Financial Management
- hdu 2005
- 实用算法实现-第 5 篇二分查找树
- 词法分析器
- hdu求平均成绩
- 孙鑫视频教程第九课——工具栏、状态栏、启动画面
- eygle 期待与拥抱变化 - 谈谈技术人的技术路
- 实用算法实现-第6篇线段树