Learn C++ from a baby! Record the questions in the process of Luogu C++ learning and test preparation, and record every moment.
Attached is a summary post: Luogu Brush Questions C++ Language | Summary
【Description】
Everyone knows that some office software has the function of automatically converting letters to uppercase. Enter a string of length 100 or less and does not include spaces. All lowercase letters in the string are required to be changed to uppercase and output.
【enter】
Enter a line, a string.
【Output】
Output a string that converts all lowercase letters in the original string to uppercase letters.
【Input example】
Luogu4!
【Example of output】
LUOGU4!
【Code Explanation】
#include <bits/stdc++.h>
using namespace std;
int main()
{
string s;
cin >> s;
for (int i=0; i<s.length(); i++) {
if (s[i]<='z' && s[i]>='a') {
//小写转大写
s[i] = s[i] - 'a' + 'A';
}
}
cout << s;
return 0;
}
【operation result】
Luogu4!
LUOGU4!