您的位置:首页 > 编程语言 > C语言/C++

大小写转换 (sdut oj)

2017-02-01 20:14 176 查看




大小写转换

Time Limit: 1000MS Memory Limit: 65536KB


Problem Description

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




Input

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




Output

 输出转换后的字符串




Example Input

A*
B+





Example Output

a*
b+





Hint

 


Author

 zmx

参考代码

#include<stdio.h>
#include<string.h>
int main()
{
char a[100];
char b[100];
int n;
int i;
while(gets(a) != NULL)
{
n = strlen(a);
for(i = 0; i < n; i++)
{
if(a[i] >= 'a' && a[i] <= 'z')
{
b[i] = a[i] - 32;
}
else if(a[i] >= 'A' && a[i] <= 'Z')
{
b[i] = a[i] + 32;
}
else
{
b[i] = a[i];
}
}

for(i = 0; i < n; i++)
{
printf("%c",b[i]);
}
printf("\n");
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  OJ SDUT c语言 二维数组