Răspuns:
#include <iostream>
using namespace std;
int main()
{
int n;
cin >> n;
int v[n];
int i,j;
for (i=0; i<n; i++) {
cin >> v[i];
}
bool oglindit=true;
int a, b;
i=0; j=n-1;
while (j-i>=1 && oglindit) {
b=v[i]; a=0;
while (b) {
a=a*10+(b%10);
b/=10;
}
if (a!=v[j]) oglindit=false;
++i; --j;
}
if (oglindit && j==i) {
int vc[20], nc=0;
b=v[i];
vc[nc++]=b%10;
b/=10;
while (b>9) {
vc[nc++]=b%10;
b/=10;
}
if (b) vc[nc++]=b;
i=0; j=nc-1;
while (j-i>=1 && oglindit) {
if (vc[i]!=vc[j]) oglindit=false;
++i; --j;
}
}
if (oglindit) cout << " sir oglindit";
else cout << " sirul nu-i bine oglindit";
return 0;
}
Explicație: