HDU 3079 Vowel Counting

来源:互联网 发布:单片机 精确测量电阻 编辑:程序博客网 时间:2024/06/04 20:09

Vowel Counting

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 824    Accepted Submission(s): 645


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
4XYzapplicationqwcvbaeioOa
 

Sample Output
xyzApplIcAtIOnqwcvbAEIOOA
 
这题就是将元音字母变成大写,辅音字母变成小写。
AC代码:
#include<iostream>#include<string.h>#include<ctype.h>using namespace std;int main(){    int n,l,i;    char s[55];    while(scanf("%d",&n)!=EOF)    {        while(n--)        {            getchar();            scanf("%s",s);            l=strlen(s);            for(i=0;i<l;i++)            {                if(s[i]>='A'&&s[i]<='Z')                {                if(s[i]=='A'||s[i]=='I'||s[i]=='E'||s[i]=='O'||s[i]=='U')printf("%c",s[i]);                else printf("%c",tolower(s[i]));                }                else                {                    if(s[i]=='a'||s[i]=='i'||s[i]=='o'||s[i]=='u'||s[i]=='e')printf("%c",toupper(s[i]));                    else                        printf("%c",s[i]);                }            }            printf("\n");        }    }    return 0;}


原创粉丝点击