题目描述:
把一个字符串中所有出现的大写字母都替换成小写字母,同时把小写字母替换成大写字母。
输入格式:
输入一行:待互换的字符串。
输出格式:
输出一行:完成互换的字符串(字符串长度小于80)。
样例输入:
If so, you already have a Google Account. You can sign in on the right.
样例输出:
iF SO, YOU ALREADY HAVE A gOOGLE aCCOUNT. yOU CAN SIGN IN ON THE RIGHT.
时间限制: 1000ms
空间限制: 128MB
代码如下:
#include<bits/stdc++.h>
using namespace std;
int main(){
char a[1001];
cin.getline(a,1001);
int s=strlen(a);
for(int i=0;i<s;i++){
if(a[i]>='a'&&a[i]<='z'){
a[i]=a[i]-32;
}
else if(a[i]>='A'&&a[i]<='Z'){
a[i]=a[i]+32;
}
}
cout<<a;
return 0 ;
}