help全TLE

P1914 小书童——凯撒密码

MoGGGG @ 2024-06-08 16:01:26

萌新大胆提问wwww

#include<iostream>
using namespace std;
int main(){
    int n,i=1;char s;
    cin>>n;
    cin.get(s);
    while(1){
        cin.get(s);
        if(s=='\n'){
            break;
        }
        if(s+n<='z'){
            cout<<char(s+n);
        }
        else{
            cout<<char(s+n-26);
        }
    }
    return 0; 
}

by elbissoPtImaerD @ 2024-06-08 16:04:12

换行符的问题,Linux 系统和 Windows 系统换行符不同,所以不一定能以 \n 作为行末标识符


by MoGGGG @ 2024-06-08 16:14:53

@elbissoPtImaerD 我脑子发霉了


by scp020 @ 2024-06-08 16:51:01

等下,那说明这题数据错了啊


by scp020 @ 2024-06-08 16:52:23

https://help.luogu.com.cn/manual/luogu/problem/testcase-format#%E6%A0%BC%E5%BC%8F%E8%A6%81%E6%B1%82


by csxx601cjy @ 2024-06-08 17:14:00

#include<bits/stdc++.h>
using namespace std;
string a,zi("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz");
int main()
{
    int n;
    cin>>n>>a;
    for(int i=0;i<=a.length()-1;i++)
        cout<<zi[zi.find(a[i])+n];
    return 0;
} 

by jljlzzz @ 2024-07-22 16:56:07

所以为啥不用string?


|