Vowel Counting

本文介绍了如何通过编程解决Vowel-Counting-Word问题,包括输入样例、输出样例及实现代码。重点在于字符转换逻辑,即将大写元音转换为小写,保持小写字母不变。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Vowel Counting

Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 32768/32768K (Java/Other)
Total Submission(s) : 58   Accepted Submission(s) : 18
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
 

 

Author
AppleMan
 

 

Source
HDU 2nd “Vegetable-Birds Cup” Programming Open Contest
 
 1 #include <stdio.h>
 2 #include <stdlib.h>
 3 #include <string.h>
 4 
 5 int main()
 6 {
 7   int T,L,i;
 8   char a[50];
 9   scanf("%d",&T);
10   while(T--)
11   {
12       scanf("%s",a);
13       L=strlen(a);
14       for(i=0;i<L;i++)
15       {
16         if(a[i]=='a'||a[i]=='e'||a[i]=='i'||a[i]=='o'||a[i]=='u')
17         {
18             a[i]-=32;
19             continue;
20         }
21         else if(a[i]=='A'||a[i]=='E'||a[i]=='I'||a[i]=='O'||a[i]=='U')
22         {
23             continue;
24         }
25         else
26         {
27             if(a[i]>='A'&&a[i]<='Z')
28             {
29                 a[i]+=32;
30                 continue;
31             }
32         }
33       }
34       printf("%s\n",a);
35   }
36   return 0;
37 }
View Code

 

转载于:https://www.cnblogs.com/Wurq/p/3750263.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值