SHARE
TWEET

Untitled

a guest Mar 20th, 2019 45 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <string>
  3. #include <stack>
  4. #include <algorithm>
  5. #include <cmath>
  6. #include <utility>
  7. #include <list>
  8. #include <vector>
  9. #include <map>
  10.  
  11. using namespace std;
  12.  
  13. bool num(char x) {
  14.     if((int)x >= (int)'0' && (int)x <= (int)'9') return true;
  15.     return false;
  16. }
  17.  
  18. bool coincidence (string person, string pattern) {
  19.     vector <char> per;
  20.     vector <char> pat;
  21.  
  22.     for (int i = 0; i < person.length(); i++) {
  23.         if (num(person[i])) per.push_back(person[i]);
  24.     }
  25.  
  26.     for (int i = 0; i < pattern.length(); i++) {
  27.         if (num(pattern[i])) pat.push_back(pattern[i]);
  28.         if (pattern[i] == 'X') {
  29.             while (pattern[i] == 'X') {
  30.                 pat.push_back(pattern[i]);
  31.                 i++;
  32.             }
  33.             break;
  34.         }
  35.     }
  36.  
  37.     if (per.size() == pat.size()) {
  38.         int i = 0;
  39.         while (pat[i] != 'X') {
  40.             if (pat[i] != per[i]) return false;
  41.             i++;
  42.         }
  43.  
  44.  
  45.         i = 0;
  46.         int counter = 0;
  47.         while(pattern[i] != 'X') {
  48.             if(pattern[i] == pat[counter]) counter++;
  49.             cout << pattern[i];
  50.             i++;
  51.         }
  52.  
  53.         for (int s = counter + 1; s < per.size(); s++) cout << per[s];
  54.  
  55.         for (int s = 0; s < pattern.length(); s++) {
  56.             if (pattern[s] != 'X') continue;
  57.             while (pattern[s] == 'X') s++;
  58.             for (int k = s; k < pattern.length(); k++) cout << pattern[k];
  59.             break;
  60.         }
  61.  
  62.         cout << endl;
  63.         return true;
  64.     }
  65.     return false;
  66. }
  67.  
  68.  
  69.  
  70. int main()
  71. {
  72.     int n, m;
  73.     cin >> n;
  74.     vector <string> person(n);
  75.     string tmp;
  76.     getline(cin, tmp);
  77.     for (int i = 0; i < n; i++) {
  78.         getline(cin, tmp);
  79.         person[i] = tmp;
  80.     }
  81.     cin >> m;
  82.     vector <string> pattern(m);
  83.     getline(cin, tmp);
  84.     for (int i = 0; i < m; i++) {
  85.         getline(cin, tmp);
  86.         pattern[i] = tmp;
  87.     }
  88.  
  89.     for (int i = 0; i < n; i++) {
  90.         for (int j = 0; j < m; j++) coincidence(person[i], pattern[j]);
  91.     }
  92.  
  93.     return 0;
  94. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top