Răspuns :
#include <iostream>
using namespace std;
int n,m,a[101][101];
int main()
{
cin >> n >> m;
for(int i = 1 ; i <= n ; ++i)
for(int j = 1 ; j <= m ; ++j)
cin >> a[i][j];
int imax = 1 ,imin = 1, jmax = 1, jmin = 1;
for(int i = 1 ; i <= n ; ++i)
for(int j = 1 ; j <= m ; ++j)
{
if(a[i][j] > a[imax][jmax])
imax = i, jmax = j;
if(a[i][j] < a[imin][jmin])
imin = i, jmin = j;
}
if(imin > imax)
{
int aux = imin; imin = imax; imax = aux;
}
if(jmin > jmax)
{
int aux = jmin; jmin = jmax; jmax = aux;
}
//eliminam linia imax
for(int i = imax ; i < n ; i ++)
for(int j = 1 ; j <= m ; j ++)
a[i][j] = a[i+1][j];
n --;
if(imin != imax)
{
//eliminam si linia imin
for(int i = imin ; i < n ; i ++)
for(int j = 1 ; j <= m ; j ++)
a[i][j] = a[i+1][j];
n --;
}
//eliminam coloana jmax
for(int i =1 ; i <= n ; i ++)
for(int j = jmax ; j < m ; j ++)
a[i][j] = a[i][j+1];
m --;
if(jmin != jmax)
{
// eliminam si coloana jmin
for(int i =1 ; i <= n ; i ++)
for(int j = jmin ; j < m ; j ++)
a[i][j] = a[i][j+1];
m --;
}
for(int i = 1 ; i <= n ; ++i)
{
for(int j = 1 ; j <= m ; ++j)
cout << a[i][j] << " ";
cout << endl;
}
return 0;
}
using namespace std;
int n,m,a[101][101];
int main()
{
cin >> n >> m;
for(int i = 1 ; i <= n ; ++i)
for(int j = 1 ; j <= m ; ++j)
cin >> a[i][j];
int imax = 1 ,imin = 1, jmax = 1, jmin = 1;
for(int i = 1 ; i <= n ; ++i)
for(int j = 1 ; j <= m ; ++j)
{
if(a[i][j] > a[imax][jmax])
imax = i, jmax = j;
if(a[i][j] < a[imin][jmin])
imin = i, jmin = j;
}
if(imin > imax)
{
int aux = imin; imin = imax; imax = aux;
}
if(jmin > jmax)
{
int aux = jmin; jmin = jmax; jmax = aux;
}
//eliminam linia imax
for(int i = imax ; i < n ; i ++)
for(int j = 1 ; j <= m ; j ++)
a[i][j] = a[i+1][j];
n --;
if(imin != imax)
{
//eliminam si linia imin
for(int i = imin ; i < n ; i ++)
for(int j = 1 ; j <= m ; j ++)
a[i][j] = a[i+1][j];
n --;
}
//eliminam coloana jmax
for(int i =1 ; i <= n ; i ++)
for(int j = jmax ; j < m ; j ++)
a[i][j] = a[i][j+1];
m --;
if(jmin != jmax)
{
// eliminam si coloana jmin
for(int i =1 ; i <= n ; i ++)
for(int j = jmin ; j < m ; j ++)
a[i][j] = a[i][j+1];
m --;
}
for(int i = 1 ; i <= n ; ++i)
{
for(int j = 1 ; j <= m ; ++j)
cout << a[i][j] << " ";
cout << endl;
}
return 0;
}