#include <fstream>
using namespace std;
ifstream fin("date.in");
ofstream fout("date.out");
int main()
{
int n,m,a[100][100],ok;
fin>>n>>m;
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++) fin>>a[i][j];
for(int i=1;i<=n;i++)
{
ok=1;
for(int j=2;j<m;j++)
if(a[i][j-1]<=a[i][j] && a[i][j]>=a[i][j+1] || a[i][j-1]>=a[i][j] && a[i][j]<=a[i][j+1]) ok=0;
if(!ok)
{
for(int k=i;k<n;k++)
for(int j=1;j<=m;j++) a[k][j]=a[k+1][j];
n--;
i--;
}
}
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++) fout<<a[i][j]<<" ";
fout<<endl;
}
fin.close();
fout.close();
return 0;
}
|