Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <vector>
- #include <unordered_set>
- void Split(const std::string& text, std::unordered_set<std::string>& words_in_text){
- std::string word;
- for (int i = 0; i < text.size(); ++i){
- if (text[i] == ' '){
- words_in_text.insert(word);
- word.clear();
- }
- else {
- word += text[i];
- }
- }
- words_in_text.insert(word);
- }
- char CyclicShift(char s){
- if (s >= 65 && s <= 90){
- return ((s - 64) % 26) + 65;
- }
- if (s >= 97 && s <= 122){
- return ((s - 96) % 26) + 97;
- }
- }
- int main() {
- std::string text;
- std::getline(std::cin, text);
- int n;
- std::cin >> n;
- std::vector<std::string> words(n);
- for (int i = 0; i < n; ++i){
- std::cin >> words[i];
- }
- std::unordered_set<std::string> words_in_text;
- Split(text, words_in_text);
- for (auto& word: words){
- for (int k = 0; k < 26; ++k){
- for (auto& s: word){
- s = CyclicShift(s);
- }
- if (words_in_text.find(word) != words_in_text.end()){
- std::cout << word << std::endl;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement