Submission

Status:

PPPPPPPPPP

Subtask/Task Score:

100/100

Score: 100

User: cyblox_boi

Problemset: ครัวซองค์รสซีซาร์

Language: cpp

Time: 0.003 second

Submitted On: 2026-01-01 03:09:42

#include <bits/stdc++.h>
using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n;
    cin >> n;

    string text;
    cin.ignore();
    getline(cin, text);

    for (int i = 0; i < text.length(); i++)
    {
        if (isalpha(text[i]))
        {
            int temp = text[i] - n;
            bool isUpper = isupper(text[i]);

            if (isUpper)
            {
                temp -= 'A';
            }
            else
            {
                temp -= 'a';
            }

            if (temp < 0)
            {
                temp += 26;
            }

            temp %= 26;

            if (isUpper)
            {
                cout << (char)(temp + 'A');
            }
            else
            {
                cout << (char)(temp + 'a');
            }
        }
        else
        {
            cout << text[i];
        }
    }

    cout << '\n';

    return 0;
}