Răspuns:
#include <iostream>
using namespace std;
int invers(int nr)
{
int inv=0;
while(nr!=0)
{
inv=inv*10+nr%10;
nr/=10;
}
return inv;
}
void afisCif(int nr)
{
while(nr!=0)
{
cout<<nr%10<<" ";
nr/=10;
}
}
void afisSCif(int nr)
{
int s=0;
while(nr!=0)
{
s+=nr%10;
nr/=10;
}
cout<<s<<" ";
}
int main()
{
int n;
cout<<"Lungime vector:";
cin>>n;
int a[n];
///citire
for(int i=0; i<n; i++)
{
cout<<"a["<<i<<"]=";
cin>>a[i];
}
cout<<"Afisare cifre:"<<endl;
for(int i=0; i<n; i++)
{
cout<<"Element "<<i<<":";
afisCif(a[i]);
cout<<endl;
}
cout<<"Afisare suma cifre:"<<endl;
for(int i=0; i<n; i++)
{
cout<<"Element "<<i<<":";
afisSCif(a[i]);
cout<<endl;
}
cout<<"Afisare elemente palindrom:"<<endl;
for(int i=0; i<n; i++)
{
if(invers(a[i])==a[i])
cout<<a[i]<<" ";
}
return 0;
}
Explicație: