Răspuns :
Salut!
Ai rezolvarea in limbajul C++ mai jos
#include <iostream>
using namespace std;
int sumCif(int n)
{
int s = 0;
while (n)
{
s += n % 10;
n /= 10;
}
return s;
}
bool prim(int n)
{
if (n <= 1)
{
return false;
}
else if (n != 2 && n % 2 == 0)
{
return false;
}
for (int i = 3; i * i <= n; i += 2)
{
if (n % i == 0)
{
return false;
}
}
return true;
}
int oglindit(int n)
{
int ogl = 0;
while (n)
{
ogl = ogl * 10 + n % 10;
n /= 10;
}
return ogl;
}
int nrNou(int n)
{
int putere = 1, nr = 0, b[11];
while (n)
{
int c = n % 10;
if (c % 2 == 0)
{
b[putere] = c;
putere++;
}
n /= 10;
}
putere--;
for (int i = putere; i >= 1; --i)
{
if (b[i] % 2 == 0)
{
nr = nr * 10 + b[i];
}
}
return nr;
}
int main()
{
int n, a[101], maxi = -1;
cin >> n;
for (int i = 1; i <= n; ++i)
{
cin >> a[i];
if (sumCif(a[i]) >= maxi)
{
maxi = sumCif(a[i]);
}
}
//cerinta a
for (int i = 1; i <= n; ++i)
{
if (sumCif(a[i]) == maxi)
{
cout << a[i] << " ";
}
}
cout << '\n';
//cerinta b
for (int i = 1; i <= n; ++i)
{
if (prim(oglindit(a[i])))
{
cout << a[i] << " ";
}
}
cout << '\n';
//cerinta c
for (int i = 1; i <= n; ++i)
{
cout << nrNou(a[i]) << " ";
}
return 0;
}