Răspuns:
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("palindrom.in");
ofstream g("palindrom.out");
bool palindrom(int n)
{
if(n<10)
return true;
int inv=n%10,m=n/10;
while(m)
{
inv=inv*10+m%10;
m/=10;
}
if(inv==n)
return true;
return false;
}
int main()
{
int x;
while(f>>x)
if(palindrom(x)==true)
g<<x<<" ";
return 0;
}
Explicație: