版权声明:知识不设限,可自由转载,请附上连接: https://blog.csdn.net/qq_44475551/article/details/89626566
题目
将下面的字符串中的大小写进行转换.
输入
输入一行字符串.
输出
将其中的大写转换为小写,小写转换为大写.
样例输入
ABCd
样例输出
abcD
源代码
#include <stdio.h>
#include <string.h>
int main()
{
char s[100];
while(~scanf("%s", s))
{
int n;
n = strlen(s);
for(int i=0; i<n; i++)
{
if(s[i] >= 'A' && s[i] <= 'Z')
printf("%c", s[i]+32);
else if(s[i] >= 'a' && s[i] <= 'z')
printf("%c", s[i]-32);
}
printf("\n");
}
return 0;
}