Răspuns :
Nu stiu asa C++ si am facut dupa cum am stiu. Sa iti fie de folos. Eu am facut dupa mine. Tu faci cum doresti acuma :D
#include <iostream>
#include <math.h> // pt sqrt
using namespace std;
bool prim(int n)
{
if(n==1)
return false;
for(int i = 2;i < (int)(sqrt(n)+1);i++)
if(n%i==0)
return false;
return true;
}
int main()
{
int a[105][105],n = 4,m = 6;
for(int i=0;i<n;i++)
for(int j=0;j<m;j++)
cin>>a[i][j];
//Afisam matricea initiala
for(int i =0;i<n;i++)
{
for(int j =0;j<m;j++)
cout<< a[i][j]<<" ";
cout<<endl;
}
for(int i=0;i<n;i++)
if(prim(a[i][0]))
for(int j=0;j<m/2;j++)
{
int aux = a[i][j];
a[i][j] = a[i][m -1 -j];
a[i][m -1 -j] = aux;
}
cout<<endl;
//Afisam matricea finala
for(int i =0;i<n;i++)
{
for(int j =0;j<m;j++)
cout<< a[i][j]<<" ";
cout<<endl;
}
return 0;
}