2014
03-01

# Vowel Counting

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.

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.

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.

4
XYz
application
qwcvb
aeioOa 

xyz
ApplIcAtIOn
qwcvb
AEIOOA

#include <iostream>
#include <string>
using namespace std;
int main()
{
int n,i;
char a[30];
while(cin>>n)
{
while(n--)
{
cin>>a;
for(i=0;i<strlen(a)+1;i++)
{
if(a[i]=='a'||a[i]=='e'||a[i]=='i'||a[i]=='o'||a[i]=='u')
a[i]=char(a[i]-32);
else
if(a[i]=='B'||a[i]=='C'||a[i]=='D'||a[i]=='F'||a[i]=='G'||a[i]=='H'||a[i]=='J'||a[i]=='K'||a[i]=='L'||a[i]=='M'||a[i]=='N'||a[i]=='P'||a[i]=='Q'||a[i]=='R'||a[i]=='S'||a[i]=='T'||a[i]=='V'||a[i]=='W'||a[i]=='X'||a[i]=='Y'||a[i]=='Z')
a[i]=char(a[i]+32);
}
cout<<a<<endl;
}
}
return 0;
}

1. 这道题目虽然简单，但是小编做的很到位，应该会给很多人启发吧！对于面试当中不给开辟额外空间的问题不是绝对的，实际上至少是允许少数变量存在的。之前遇到相似的问题也是恍然大悟，今天看到小编这篇文章相见恨晚。