7-139 4201 凯撒密码

#include <algorithm>
#include <cstdint>
#include <iostream>
#include <limits>
#include <numeric>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using i32 = std::int32_t;
using i64 = std::int64_t;
using u32 = std::uint32_t;
using u64 = std::uint64_t;
using pii = std::pair<i32, i32>;
using pll = std::pair<i64, i64>;
using vi = std::vector<i32>;
using vll = std::vector<i64>;
using vpii = std::vector<pii>;
using vpll = std::vector<pll>;

void solve();

int main()
{
    std::cin.tie(nullptr)->sync_with_stdio(false);
    solve();
}

char single_encrypt(char x)
{
    if (std::isupper(x))
        return (x - 'A' - 5 + 26) % 26 + 'A';
    return x;
}

std::string encrypt(const std::string &str)
{
    std::string res;
    for (auto &item : str)
    {
        res += single_encrypt(item);
    }
    return res;
}

void solve()
{
    std::string get;
    bool start{false};
    bool endl{false};
    while (std::getline(std::cin, get))
    {
        if (get == "START")
        {
            start = true;
            continue;
        }
        else if (get == "END")
        {
            start = false;
            continue;
        }
        if (start)
        {
            if (endl)
            {
                std::cout << '\n';
            }
            std::cout << encrypt(get);
            endl = true;
        }
    }
}
posted @ 2025-10-15 08:58  TPPPP72  阅读(5)  评论(0)    收藏  举报