Răspuns:
#include <iostream>
using namespace std;
short a,b,c,d,e;
int main()
{
for (a=1; a<=5; ++a)
{
for (b=a+1; b<=6; ++b)
for (c=b+1; c<=7; ++c)
for (d=c+1; d<=8; ++d)
for (e=d+1; e<=9; ++e)
cout <<a<<b<<c<<d<<e<<d<<c<<b<<a<< endl;
}
}
Explicație: