Răspuns :
Răspuns:
#include <iostream>
using namespace std;
int main()
{
int n,m;
cout<<"Numarul de linii : ";cin>>n;cout<<endl;
cout<<"Numarul de coloane : ";cin>>m;cout<<endl;
int MAT[n][n];
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
cin>>MAT[i][j];
}
}
int maxx=MAT[0][0];
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
if(maxx<MAT[i][j])
maxx=MAT[i][j];
}
}
int prod=1;
for(int i=0;i<n;i++){
for(int j=i+1;j<m;j++){
if(MAT[i][j]%5==0)
prod*=MAT[i][j];
}}
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
if(MAT[i][j]%2!=0)
MAT[i][j]=maxx;
}
}
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
cout<<MAT[i][j]<<" ";
}
cout<<endl;
}
cout<<"Produsul elementelor divizibile cu 5 de pe diagonala superioare : ";
if(prod==1)
cout<<0;
else
cout<<prod;
return 0;
}
Explicație: