萌新在vs上运行正常,但洛谷上编译失败,求大佬教教

P1914 小书童——凯撒密码

Falcone @ 2023-09-06 16:46:34

这里是代码


#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
    int n,l=0;
    cin >> n;
    string str1;
    cin >> str1;
    l = size(str1);
    for (int i = 0; i<=l-1;i++)
    {
        str1[i] += n;
        if (str1[i] > 'z')
        {
            int t = (int)str1[i]-122;
            str1[i] = (t % 26) + 'a'-1;
        }
    }
    cout << str1;
    return 0;
}

by dthythxth_Huge_Brain @ 2023-09-06 17:02:41

@Falcone 是 str1.size(),不是size(str1)


by dthythxth_Huge_Brain @ 2023-09-06 17:03:31

@Falcone 但貌似 c++20 是可以编译的。。。


by Falcone @ 2023-09-25 15:55:27

@Huge_Brain 学到了,谢谢~


|