首页 > 其他 > 详细

1042: 元音字母转换

时间:2019-01-27 12:35:36      阅读:314      评论:0      收藏:0      [点我收藏+]

题目描述

给你一个字符串,现要求你对其进行处理,使得处理后的字符串满足如下要求:
字符串里面的元音字母全部为大写;
其余字母全部为小写。

输入

输入的第一行为一个正整数T(T<=20),表示测试数据的个数。
每个输入的字符串只包含大写字母和小写字母。字符串长度不超过50。

输出

对于每一个测试数据,输出其对应的结果。每个结果占一行。

样例输入

4
XYz
application
qwcvb
aeioOa

样例输出

xyz
ApplIcAtIOn
qwcvb
AEIOOA

 1 #include<stdio.h>
 2 #include<string.h>
 3 #include<iostream>
 4 using namespace std;
 5 int main(){
 6     int n;
 7     scanf("%d",&n);
 8     while(n--){
 9         char str[50];
10         char temp[10]={a,e,i,o,u,A,E,I,O,U};
11         scanf("%s",str);
12             int len=strlen(str);
13             for(int i=0;i<len;i++){
14                 int flag=1;
15                 for(int j=0;j<10;j++){
16                     if(str[i]==temp[j]){
17                         flag=0;
18                         if(str[i]>=a&&str[i]<=z){
19                             printf("%c",str[i]-32);
20                         }else{
21                             printf("%c",str[i]);
22                         }
23                         break;
24                     }
25                 }
26                 if(flag!=0){
27                     if(str[i]>=A&&str[i]<=Z){
28                             printf("%c",str[i]+32);
29                         }else{
30                             printf("%c",str[i]);
31                         }
32                 }
33                 
34             }
35             printf("\n");
36     }
37     return 0;
38 } 

Mist笔记:首先解决这题你要知道元音字母有哪些,aeiou就是这五个。写这道题有些细节需要注意,反正我自己出了bug,多重循环容易出问题。

 

1042: 元音字母转换

原文:https://www.cnblogs.com/mist2019/p/10325920.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!