Josif_tepe

Untitled

May 28th, 2026
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.01 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6.     string s;
  7.     cin >> s;
  8.    
  9.     int n;
  10.     cin >> n;
  11.    
  12.     string niza[n];
  13.    
  14.     int prisuten = -1;
  15.     for(int i = 0; i < n; i++) {
  16.         cin >> niza[i];
  17.        
  18.         if(niza[i] == s) {
  19.             prisuten = 1;
  20.         }
  21.     }
  22.    
  23.     if(prisuten == -1) {
  24.         cout << s << endl;
  25.         return 0;
  26.     }
  27.    
  28.     for(int i = 1; i <= 201; i++) {
  29.         string s1 = s;
  30.        
  31.         string i_str = "";
  32.         int tmp = i;
  33.         while(tmp > 0) {
  34.             int cifra = tmp % 10;
  35.             tmp /= 10;
  36.             i_str += (cifra + '0');
  37.         }
  38.         reverse(i_str.begin(), i_str.end());
  39.        
  40.         s1 += i_str;
  41.        
  42.         int postoi = -1;
  43.         for(int j = 0; j < n; j++) {
  44.             if(s1 == niza[j]) {
  45.                 postoi = 1;
  46.             }
  47.         }
  48.        
  49.         if(postoi == -1 ){
  50.             cout << s1 << endl;
  51.             break;
  52.         }
  53.     }
  54.     return 0;
  55. }
  56.  
Advertisement
Add Comment
Please, Sign In to add comment