文章目录
大小写转换
题目5813: 大小写转换
链接:http://codeup.cn/problem.php?id=5813
题目描述
读入一些字符串,将其中的小写字母转成大写字母(其他字符不变)。
输入
输入为多行,每行为一个字符串,字符串只由字母和数字组成,长度不超过80。输入以“End of file”结束。
输出
对于每行输入,输出转换后的字符串。
样例输入 Copy
Hello
ICPC2004
12345abcde
样例输出 Copy
HELLO
ICPC2004
12345ABCDE
代码
//5813: 大小写转换
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main(){
string str;
while(cin>>str){
getchar();
int len = str.length();
for(int i = 0;i < len;i++){
if(str[i] >='a' && str[i] <= 'z'){
str[i] -= 32;
}
}
cout<<str<<endl;
}
return 0;
}