C 大小写转换 SDUT

耗尽温柔 提交于 2019-12-13 20:16:39

Time Limit: 1000 ms Memory Limit: 65536 KiB


Problem Description

X现在要学习英文以及各种稀奇古怪的字符的了。现在他想把一串字符中的小写字母变成大写字符,大写字母变成小写字母,其他的保持不变。


Input

输入有多组。
每组输入一个字符串,长度不大于80,不包含空格。


Output

输出转换后的字符串


Sample Input

A*
B+


Sample Output

a*
b+


Hint

Source
zmx

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
   int main()
   {
       char a[81];
       int n,i;
       while(gets(a)!=NULL)
       {
           n = strlen(a);
           for(i=0;i<n;i++)
           {
               if(a[i]<='z'&&a[i]>='a')
                a[i] = a[i] -32;        //小写化大写;
               else if(a[i]<='Z'&&a[i]>='A')
                a[i]  = a[i] +32;      //大写化小写;
           }
           puts(a);
       }

       return 0;
   }

运行结果:
A*
a*
B+
b+
^Z

Process returned 0 (0x0)   execution time : 9.134 s
Press any key to continue.
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!