洛谷P5733 【深基6.例1】自动修正

本题非常简单,输入字符串后线性遍历,遇到小写字符即转换为大写(小写字符ASCII码范围97~122),输出即可。

#include <bits/stdc++.h>

using namespace std;

string s;

int main () {
	
	cin >> s;
	
	for (int i = 0; i < s.length(); i++) {
		if (s[i] >= 97 && s[i] <= 122) s[i] -= 32;
		cout << s[i];
	}
	
	return 0;
}

猜你喜欢

转载自blog.csdn.net/Runcode8/article/details/130510180