Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- string s;
- cin >> s;
- int n;
- cin >> n;
- string niza[n];
- int prisuten = -1;
- for(int i = 0; i < n; i++) {
- cin >> niza[i];
- if(niza[i] == s) {
- prisuten = 1;
- }
- }
- if(prisuten == -1) {
- cout << s << endl;
- return 0;
- }
- for(int i = 1; i <= 201; i++) {
- string s1 = s;
- string i_str = "";
- int tmp = i;
- while(tmp > 0) {
- int cifra = tmp % 10;
- tmp /= 10;
- i_str += (cifra + '0');
- }
- reverse(i_str.begin(), i_str.end());
- s1 += i_str;
- int postoi = -1;
- for(int j = 0; j < n; j++) {
- if(s1 == niza[j]) {
- postoi = 1;
- }
- }
- if(postoi == -1 ){
- cout << s1 << endl;
- break;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment