题意:元音大写,辅音小写。
#include<iostream>
#include<string>
using namespace std;
int main(){
int n;
cin>>n;
while(n--){
string str;
cin>>str;
// 把大写全部转换成小写
for(int i=0;i<str.length();i++){
if(isupper(str[i])){
str[i] = str[i] - 'A' + 'a';
}
}
// 把元音字母转换成大写
for(int i=0;i<str.length();i++){
switch(str[i]){
case 'a':
case 'e':
case 'i':
case 'o':
case 'u':
str[i] = str[i] - 'a' + 'A';
}
}
// 输出结果
cout<<str<<endl;
}
return 0;
}
Vowel Counting
元音统计
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1673 Accepted Submission(s): 1233
Problem Description
The "Vowel-Counting-Word"(VCW), complies with the following conditions.
单词元音计数,简称VCW,遵照下面列出的条件。
Each vowel in the word must be uppercase.
Each vowel in the word must be uppercase.
每一个单词中的元音必须用大写;
Each consonant (the letters except the vowels) must be lowercase.
Each consonant (the letters except the vowels) must be lowercase.
每一个单词中的辅音字母必须用小写。
For example, "ApplE" is the VCW of "aPPle", "jUhUA" is the VCW of "Juhua".
For example, "ApplE" is the VCW of "aPPle", "jUhUA" is the VCW of "Juhua".
例如:“ ApplE ” 的元音计数是“ aPPle "(这个写法是反的),"jUhUA"的元音计数是"Juhua".
Give you some words; your task is to get the "Vowel-Counting-Word" of each word.
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.
输入的第一行包含一个正整数T,他表示测试事件的个数。
For each case, there is a line contains the word (only contains uppercase and lowercase).
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.
单词的长度不会大于50。
Output
For each case, output its Vowel-Counting-Word.
对与每一个测试事件,输出元音大写,辅音小写的格式。
Sample Input
4 XYz application qwcvb aeioOa
Sample Output
xyz ApplIcAtIOn qwcvb AEIOOA
Author
AppleMan