Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <map>
- #include <vector>
- #include <stdio.h>
- #include <string>
- #define ll long long
- using namespace std;
- map <char, ll> letter;
- string qwerty = "qwertyuiopasdfghjklzxcvbnm";
- string s;
- ll shift;
- void mapping() {
- for (ll i = 0; i < 26; i++) {
- letter[qwerty[i]] = i;
- }
- }
- char transformation(char a, ll cshift) {
- if (cshift == 0) return a;
- ll index = letter[a];
- if (cshift < 0) index += 26;
- return qwerty[index + cshift % 26];
- }
- int main() {
- //in input file you should write text on the next line after the shift number
- //you can write text on several lines
- //shift number should be in [-4 * 1e18, 4 * 1e18]
- //freopen("inputfilename", "r", stdin);
- //freopen("outputfilename", "w", stdout);
- qwerty += qwerty;
- mapping();
- cin >> shift;
- getline(cin, s);
- while (getline(cin, s)){
- for (auto i : s) {
- if (i >= 'A' && i <= 'Z') {
- cout << toupper(transformation(tolower(i), shift));
- } else if (i >= 'a' && i <= 'z') {
- cout << transformation(i, shift);
- } else {
- cout << i;
- }
- }
- cout << '\n';
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement