5. 大小写转换

题目描述

将字符串中的大写字母转为小写,小写字母转为大写

输入输出格式

输入格式

一行字符串,只包含字母,无需检查输入合法性

输出格式

一行字符串

输入输出样例

输入样例

abcdEFG

输出样例

ABCDefg

题解

水题~
离线枚举+判断+输出,秒AC!
上代码!

代码

#include<bits/stdc++.h>
using namespace std;
string s;
int main(){
    
    
	cin>>s;
	for(int i=0;i<s.size();i++){
    
    
		if(s[i]>='a'&&s[i]<='z') cout<<char(s[i]-32);
		else cout<<char(s[i]+32);
	}
	return 0;
}

猜你喜欢

转载自blog.csdn.net/JPY_Ponny/article/details/114194697