Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <sstream>
- #include <unordered_map>
- #include <string>
- using namespace std;
- char NumberToLetter(int num) {
- return static_cast<char> (num) + 'a';
- }
- int LetterToNumber(char letter) {
- return static_cast<int> (letter - 'a');
- }
- string DeltaString(const string& word) {
- string delta_string(word.size() - 1, ' ');
- for (int i = 1; i < word.size(); ++i) {
- delta_string[i - 1] = NumberToLetter((LetterToNumber(word[i]) - LetterToNumber(word[i - 1]) + 26) % 26);
- }
- return delta_string;
- }
- int main() {
- string s;
- getline(cin, s);
- stringstream ss(s);
- string decryption;
- unordered_map<string, string> answer_for_delta_string;
- while (ss >> decryption) {
- answer_for_delta_string[DeltaString(decryption)] = decryption;
- }
- //cout << DeltaString("abcd") << endl;
- int n = 0;
- cin >> n;
- for (int i = 0; i < n; ++i) {
- string cipher;
- cin >> cipher;
- cout << answer_for_delta_string[DeltaString(cipher)] << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement