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

*数组-05. 字符串字母大小写转换

时间:2014-08-23 01:03:09      阅读:151      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   color   os   io   for   ar   2014   

 1 /*
 2  * Main.c
 3  * E5-数组-05. 字符串字母大小写转换
 4  *  Created on: 2014年8月20日
 5  *      Author: Boomkeeper
 6  *********部分通过*********
 7  */
 8 
 9 #include <stdio.h>
10 
11 int main(void){
12 
13     char str[40]={-1};
14 
15     gets(str);
16 
17     int i,index;
18     for(i=0;i<40;i++){
19         if(str[i]==#){
20             index=i;
21             break;
22         }
23     }
24     //大小写转换(ASCII)
25     for(i=0;i<index;i++){
26         if(str[i]<=z&&str[i]>=a)
27             str[i]-=32;
28         else if(str[i]<=Z&&str[i]>=A)
29             str[i]+=32;
30     }
31     //输出
32     for(i=0;i<index;i++)
33         putchar(str[i]);
34     putchar(\n);
35 
36     return 0;
37 }

bubuko.com,布布扣

 

题目链接:

http://pat.zju.edu.cn/contests/basic-programming/%E6%95%B0%E7%BB%84-05

 

*数组-05. 字符串字母大小写转换

标签:style   blog   http   color   os   io   for   ar   2014   

原文地址:http://www.cnblogs.com/boomkeeper/p/E5.html

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