C++请问最后一个测试点n=0;为什么会WA?谢谢TvT

P1914 小书童——凯撒密码

nen2023 @ 2023-02-13 11:20:50

#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;
}

by reveal @ 2023-02-13 11:24:54


by nen2023 @ 2023-02-13 20:15:48

@reveal ok了,谢谢qwq


|