C++请问最后一个测试点n=0;为什么会WA?谢谢TvT
查看原帖
C++请问最后一个测试点n=0;为什么会WA?谢谢TvT
935342
nen2023楼主2023/2/13 11:20
#include<iostream>
#include<iomanip>
#include<string>
#include<algorithm>
using namespace std;

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    char* p = new char[n];
    for (int i = 0; i < s.length(); i++) {
        p[i] = s[i] + n;
        if (p[i] > 122) {
            p[i] = p[i] % 122 + 96;
       }
        cout << p[i];
    }
    system("pause");
    return 0;
}

2023/2/13 11:20
加载中...