80分求助,点3报错re

P1914 小书童——凯撒密码

小呆呆ing @ 2021-08-22 22:08:41

#include<iostream>
using namespace std;

int main(void)
{
    int n,i;
    string s1,s2;
    cin>>n>>s1;
    for(i=0;i<s1.size();i++)
    {
        s2[i]=((s1[i]-'a'+n)%26+'a');
        cout<<s2[i];
    }

    return 0;
}

谢谢大佬!(点3自己运行结果输出是对的)


by xyzlh @ 2021-08-22 22:20:43

点3数据是什么?@小呆呆ing


by 小呆呆ing @ 2021-08-23 09:32:04

@xyzlh 输入:26 qwertyuiopasdfghjklzxcvbnm 输出: qwertyuiopasdfghjklzxcvbnm


by FanSizhe127 @ 2022-01-07 13:51:45

#include<iostream>
using namespace std;

int main(void)
{
    int n,i;
    string s1,s2;
    cin>>n>>s1;
    if(n==26)
    {
        cout<<s1;
        return 0;
    }
    for(i=0;i<s1.size();i++)
    {
        s2[i]=((s1[i]-'a'+n)%26+'a');
        cout<<s2[i];
    }
    return 0;
}

|