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

题目传送门

#include <bits/stdc++.h>

using namespace std;

int main() {
    string s;
    cin >> s;
    //方式1
    for (int i = 0; i < s.size(); i++)
        printf("%c", toupper(s[i]));
    printf("\n");
    //方式2
    for (int i = 0; i < s.size(); i++)
        printf("%c", s[i] >= 'a' && s[i] <= 'z' ? s[i] - 32 : s[i]);
    printf("\n");
    //方式3
    transform(s.begin(), s.end(), s.begin(), ::toupper);
    printf("%s\n", s.c_str());
    return 0;
}
原文地址:https://www.cnblogs.com/littlehb/p/15570753.html