题解 | #简单密码#

简单密码

https://www.nowcoder.com/practice/ff99c43dd07f4e95a8f2f5448da3772a

  • 提交的输入格式与自测的格式不一致,按实际的修改外层循环终止条件就行。
#include <iostream>
using namespace std;

int main() {
    string str;
    getline(cin, str); //读取一行,丢弃\n
    // while (str!="ENDOFINPUT") {//自测的输入格式
    while (str != "END") {//提交的输入格式
        if (str == "START"||str == "END"){
            getline(cin,str);
            continue;
        }
        for (int i = 0; i < str.length(); i++) {
            if(str[i]>='A'&&str[i]<='Z') str[i]=(str[i]-'A'+26-5)%26+'A';
        }
        cout << str << endl;
        getline(cin, str); 
    }
    return 0;
}

全部评论

相关推荐

特斯联 后端开发 300 + 450餐补
点赞 评论 收藏
转发
点赞 收藏 评论
分享
牛客网
牛客企业服务