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.
来源:CSDN
作者:zhangzhaolin12
链接:https://blog.csdn.net/zhangzhaolin12/article/details/103532193