您的位置:首页 > 其它

hd acm steps 1.2.8

2014-09-14 21:08 92 查看

Vowel Counting

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 2392 Accepted Submission(s): 1326
Problem Description

The "Vowel-Counting-Word"(VCW), complies with the following conditions.

Each vowel in the word must be uppercase.

Each consonant (the letters except the vowels) must be lowercase.

For example, "ApplE" is the VCW of "aPPle", "jUhUA" is the VCW of "Juhua".

Give you some words; your task is to get the "Vowel-Counting-Word" of each word.

Input

The first line of the input contains an integer T (T<=20) which means the number of test cases.

For each case, there is a line contains the word (only contains uppercase and lowercase). The length of the word is not greater than 50.

Output

For each case, output its Vowel-Counting-Word.

Sample Input

4
XYz
application
qwcvb
aeioOa


Sample Output

xyz
ApplIcAtIOn
qwcvb
AEIOOA


/*
两点需要注意:
1.bool函数一定要true和false都要返回,而不要只返回其中之一,否则很容易出错;
2.读入的一点技巧<img src="http://img.blog.csdn.net/20140914211803562?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQveWFuZ196b25nanVu/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="" />这里在读入数字之后一定要用getchar()函数读掉其后的空格或回车,在读入一行字符串,否则出错!
*/
//@auther Yang Zongjun
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string>

using namespace std;
#define PI acos(-1.0)
#define EPS 1e-8
const int MAXN = 55;
const int INF = 2100000000;
char c[MAXN];

bool isXiaoXie_Yuanyin(char cha)
{
if(cha=='a' || cha=='e' || cha=='i' || cha=='o' || cha=='u') return true;
else return false;//开始时候没写else return false导致错误,每次他默认返回true,
//导致只执行这一个bool函数,下面的都不执行了。
//但好像有时候bool函数它默认返回false,所以每次写bool函数时一定要return true和return false都要写
//千万不要只写其中之一,这样很容易出错的!!!
}

bool isDaxie_yuanyin(char cha)
{
if(cha=='A' || cha=='E' || cha=='I' || cha=='O' || cha=='U') return true;
else return false;
}

bool isDaxie_fuyin(char cha)
{
if('B'<=cha&&cha<='Z' && cha!='E' && cha!='I' && cha!='O' && cha!='U')return true;
else return false;
}

int main()
{
//    freopen("C:/Users/Administrator/Desktop/input.txt", "r", stdin);
int n;
while(~scanf("%d", &n))
{
getchar();/*这里有一个常见技巧:就是先读入一个整数,但后面要读入一行字符串,
这样的话一定要加一个getchar()函数将整数后面的空格或者是回车读掉,否则极有可能出错!!!
*/
while(n--)
{
//memset(c, 0, sizeof(c));
gets(c);
int len = strlen(c);
//cout << c << " " << len << endl;
for(int i = 0; i < len; i++)
{
if(isXiaoXie_Yuanyin(c[i])) printf("%c", (char)(c[i]-32) );
else if(isDaxie_yuanyin(c[i])) printf("%c", (char)(c[i]));
else if(isDaxie_fuyin(c[i])) printf("%c", (char)(c[i] + 32));
else printf("%c", (char)(c[i]));
if(i == len - 1) printf("\n");
}
}
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: