#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main(){
int R,C;
scanf("%d %d\n",&R,&C);
int M1[R][C],M2[R][C];
int k=0,l=0;
memset(M1,0,(R*C)*sizeof(int));
memset(M2,0,(R*C)*sizeof(int));
for(int i=0;i<R;i++)
{
char inputLine[1001];
scanf("%[^\n] \n",inputLine);
char *ptr = strtok(inputLine," ");
l=0;
while(ptr!=NULL)
{
M1[k][l++] = atoi(ptr);
ptr = strtok(NULL," ");
}
k++;
}
k=0,l=0;
int startRow=-1,startCol=-1,endRow=-1,endCol=-1;
for(int i=0;i<R;i++)
{
for(int j=0;j<C,j++)
{
if(M1[i][j] != M2[i][j])
{
if(startRow==-1 && startCol==-1)
{
startRow = i;
startCol = j;
}
endRow = i;
endCol = j;
}
}
}
for(int i=startRow;i<=endRow;i++)
{
for(int j=startCol;j<=endCol;j++)
{
if(j==startCol) printf("%d ",M2[i][j]);
printf("%d ",M1[i][j]);
}
printf("\n");
}
}
Post a Comment