返回题解分享
讨论 / 题解分享/ 帖子详情

字符串编号(编程题) - 题解

//
// Created by 30945 on 2024/4/11.
//
#include<bits/stdc++.h>

#define int long long
#define endl '\n'

using namespace std;

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s;
    getline(cin, s);
    for (int i = 0; i < s.length(); ++i) {
        char c;
        string a = s.substr(i, 2);
        if (stoi(a) <= 26) {
            c = stoi(a) + ('A' - 1);
            i++;
        } else {
            string a = s.substr(i, 1);
            c = stoi(a) + ('A' - 1);
        }
        cout << c;
    }

    return 0;
}
0 回复 0 转发 0 喜欢 1 阅读
回复 (0)
默认 最新
暂无回复,快来抢沙发!