码迷,mamicode.com
首页 > 其他好文 > 详细

杭电oj 3079 Vowel Counting

时间:2015-06-04 22:23:44      阅读:128      评论:0      收藏:0      [点我收藏+]

标签:

 

Tips:可以先将输入的字符串全部转化为小写字母,然后再将元音字母变为大写,时间复杂度O(n)

 1 #include<stdio.h>
 2 #include<string.h>
 3 #include<ctype.h>
 4 int main()
 5 {
 6     int T;
 7     scanf("%d",&T);
 8     getchar();
 9     while(T--)
10     {
11         char ch[51];
12         gets(ch);
13         //先全部变为小写字母
14         for(int j = 0;j<strlen(ch);j++)
15         {
16             ch[j] = tolower(ch[j]);
17         }
18         for(int i = 0;i<strlen(ch);i++)
19         {
20             switch(ch[i])
21             {
22                 case a: ch[i] = A;break;
23                 case e: ch[i] = E;break;
24                 case i: ch[i] = I;break;
25                 case o: ch[i] = O;break;
26                 case u: ch[i] = U;break;
27             }
28         }
29         for(int i = 0;i < strlen(ch);i++)
30         {
31             printf("%c",ch[i]);
32         }
33         printf("\n");
34     }
35     return 0;
36 }

 

杭电oj 3079 Vowel Counting

标签:

原文地址:http://www.cnblogs.com/wujiyang/p/4553112.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!