POJ 1298 - The Hardest Problem Ever(模拟)

题目链接 https://cn.vjudge.net/problem/POJ-1298

简单模拟,每个字母往前推5个位置

#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cctype>
#include<cstring>
#include<string>
using namespace std;

int main(){
    ios::sync_with_stdio(0);
    string s1;
    while(1){
        getline(cin,s1);
        if(s1=="ENDOFINPUT") break;
        getline(cin,s1);
        for(int i=0;i<s1.length();++i){
            if(!isalpha(s1[i])) continue;
            int x=s1[i]-'A';
            x=(x-5+26)%26;
            s1[i]='A'+x;
        }
        cout<<s1<<endl;
        getline(cin,s1);
    }
    return 0;
}

猜你喜欢

转载自blog.csdn.net/xiao_k666/article/details/80599742
今日推荐