2 条题解

  • 0
    @ 2026-7-20 1:42:41

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

    解题思路

    逐个检查字符。若字符位于 az,利用大小写字母编码的固定差值转换;否则原样保留。

    复杂度分析

    时间复杂度 O(s)O(|s|),空间复杂度 O(1)O(1)(不计字符串本身)。

    C++17 参考代码

    #include <bits/stdc++.h>
    using namespace std;
    int main(){
        ios::sync_with_stdio(false);cin.tie(nullptr);
        string s;cin>>s;
        for(char &c:s) if(c>='a'&&c<='z') c=c-'a'+'A';
        cout<<s<<'\n';
        return 0;
    }
    
    • 0
      @ 2026-7-20 1:42:41

      #include <bits/stdc++.h> using namespace std; int main(){ ios::sync_with_stdio(false);cin.tie(nullptr); string s;cin>>s; for(char &c:s) if(c>='a'&&c<='z') c=c-'a'+'A'; cout<<s<<'\n'; return 0; }

      • 1

      信息

      ID
      4940
      时间
      2000ms
      内存
      256MiB
      难度
      10
      标签
      递交数
      1
      已通过
      1
      上传者