/Varianta54-s3e3.cpp Secret
Created
September 16, 2017 11:05
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
void inv(int a, int &b) { | |
b = 0; | |
while (a > 0) { | |
b = b * 10 + a % 10; | |
a = a / 10; | |
} | |
} | |
int main() { | |
int n; | |
cin>>n; | |
int stanga = n,dreapta = n; | |
while (true) { | |
int inversStanga,inversDreapta; | |
inv(stanga,inversStanga); | |
inv(dreapta,inversDreapta); | |
if (stanga == inversStanga) { | |
cout<<stanga; | |
break; | |
} | |
if (dreapta == inversDreapta) { | |
cout<<dreapta; | |
break; | |
} | |
stanga--; | |
dreapta++; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment