Răspuns:
a)
#include <iostream>
using namespace std;
int NumarMaxim(int x)
{
int Max = 0;
while (x)
{
if (x % 10 > Max)
Max = x % 10;
x /= 10;
}
return Max;
}
int main()
{
int n, x;
cin >> n;
for (int i = 1; i <= n; i++)
{
cin >> x;
cout << NumarMaxim(x);
}
return 0;
}
b)
#include <iostream>
using namespace std;
int Palindrom(int x)
{
int p = 0;
while (x)
{
p = p * 10 + x % 10;
x /= 10;
}
return p;
}
int main()
{
int n, x;
cin >> n;
for (int i = 1; i <= n; i++)
{
cin >> x;
if (x == Palindrom(x))
cout << x << " ";
}
return 0;
}
Explicație: