题解 | #简单密码#

简单密码

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

#include "cstdio"
#include "strings.h"
#include "string"
#include "string.h"

using namespace std;

int main() {
    char buf[201];
    while (scanf("%s", buf) != EOF) {
        if (0 == strcmp(buf, "ENDOFINPUT")) {
            break;
        }
        if (0 == strcmp(buf, "START")) {
            int x = getchar();
            // printf("x=%d\n", x);
            fgets(buf, sizeof buf, stdin);
            string str = buf;
            // A65 Z90
            for (int i = 0; i < str.length(); ++i) {
                if (str[i] >= 'F' && str[i] <= 'Z') {
                    str[i] = str[i] - 5;
                } else if (str[i] <= 'E' && str[i] >= 'A') {
                    str[i] = str[i] + 21;
                }
            }
            printf("%s", str.c_str());
        }
        fgets(buf, sizeof buf, stdin);
        if (0 == strcmp(buf, "END")) {
            continue;
        }
    }
    return 0;
}

全部评论

相关推荐

07-07 11:33
江南大学 Java
已经在暑假实习了&nbsp;,没有明确说有hc,纠结实习到八月份会不会有点影响秋招毕竟感觉今年好多提前批
程序员小白条:92的话准备提前批,其他没必要,没面试机会的,而且你要准备充分,尤其八股和算法题
点赞 评论 收藏
分享
点赞 评论 收藏
分享
06-10 23:36
已编辑
首都经济贸易大学 C++
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务