Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- bool palindrom(int x) {
- short y = x, z = 0;
- while (y != 0) {
- z = z * 10 + y % 10;
- y /= 10;
- }
- return x == z;
- }
- int main() {
- bool a = 0;
- int x, p, u, max;
- ifstream f("numere.in");
- ofstream g("numere.out");
- while (f >> x)
- if (palindrom(x)) {
- u = x;
- if (!a) {
- p = x;
- max = x;
- a = 1;
- }
- if (x > max)
- max = x;
- }
- g << max << endl << p << ' ' << u;
- f.close();
- g.close();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement