Răspuns :
a)
#include<iostream>
using namespace std;
int main() {
int m[101][101], v[100001], linii, coloane, nv = 0;
cin >> linii >> coloane;
for (int i = 1; i <= linii; i++)
for (int j = 1; j <= coloane; j++) {
cin >> m[i][j];
int cm = m[i][j], invm = 0;
while (cm != 0) {
invm = invm * 10 + cm % 10;
cm /= 10;
}
if (invm == m[i][j])
v[++nv] = m[i][j];
}
for (int i = 1; i <= nv; i++)
cout << v[i] << ' ';
return 0;
}
b)
#include<iostream>
using namespace std;
int main() {
int m[101][101], v[100001], linii, coloane, nv = 0;
cin >> linii >> coloane;
for (int i = 1; i <= linii; i++)
for (int j = 1; j <= coloane; j++) {
cin >> m[i][j];
int k = 0;
for (int d = 1; d <= m[i][j]; d++)
if (m[i][j] % d == 0)
k++;
if (k == 2)
v[++nv] = m[i][j];
}
for (int i = 1; i <= nv; i++)
cout << v[i] << ' ';
return 0;
}