HDU 1.2.8 Vowel Counting

Vowel Counting

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 2509 Accepted Submission(s): 1367
 
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
 

#include<stdio.h>
#include<string.h>
#include<ctype.h> //頭文件!
int main(){
int n, i, j, m;
char a[100];
scanf("%d", &n);
for (j = 1; j <= n; j++){
scanf("%s", a);
m = strlen(a) - 1;
for (i = 0; i <= m; i++){
if (a[i] == 'a' || a[i] == 'e' || a[i] == 'i' || a[i] == 'o' || a[i] == 'u')
a[i] = toupper(a[i]); //函數!
if (a[i] >= 'A'&&a[i] <= 'Z')
if (a[i] != 'A'&&a[i] != 'E'&&a[i] != 'I'&&a[i] != 'O'&&a[i] != 'U')
a[i] = tolower(a[i]); //函數!
}
printf("%s\n", a);
}
return 0;
}


發佈了48 篇原創文章 · 獲贊 3 · 訪問量 8萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章