ChatGPT只有33分
查看原帖
ChatGPT只有33分
920234
froth_reciprocal楼主2023/7/10 10:11

希望大佬高抬贵手解答一下,谢谢

愿意的话,可不可以交个朋友,我是新手

#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

string decryptString(const string& encrypted) {
    string decrypted = encrypted;

    // 循环左移三个位置
    for (int i = 0; i < decrypted.length(); i++) {
        if (isalpha(decrypted[i])) {
            decrypted[i] = ((decrypted[i] - 'A' + 3) % 26) + 'A';
        }
    }

    // 逆序存储
    reverse(decrypted.begin(), decrypted.end());

    // 大小写反转
    for (int i = 0; i < decrypted.length(); i++) {
        if (islower(decrypted[i])) {
            decrypted[i] = toupper(decrypted[i]);
        } else if (isupper(decrypted[i])) {
            decrypted[i] = tolower(decrypted[i]);
        }
    }

    return decrypted;
}

int main() {
    string encrypted;
    cin >> encrypted;

    string decrypted = decryptString(encrypted);
	cout << decrypted << endl;

    return 0;
}```

2023/7/10 10:11
加载中...