//PascalABC.NET 3.2 сборка 1318
Var
ma,mabuf:array of array of integer;
i,j,n,m,x,mark,k,h,newm,kar:integer;
begin
readln(n);
readln(m);
newm:=m;
readln(x);
setlength(ma,n);
setlength(mabuf,n);
for i:=0 to n-1 do
begin
setlength(ma[i],m);
setlength(mabuf[i],m);
end;
for i:=0 to n-1 do
for j:=0 to m-1 do
readln(ma[i][j]);
kar:=-1;
for j:=0 to m-1 do
begin
inc(kar);
for i:=0 to n-1 do
if ma[i][j]=x then
begin
inc(newm);
for h:=0 to n-1 do
setlength(mabuf[h],newm);
for h:=0 to n-1 do
mabuf[h][kar]:=0;
inc(kar);
break;
end;
for i:=0 to n-1 do
mabuf[i][kar]:=ma[i][j];
end;
for i:=0 to n-1 do
setlength(ma[i],newm);
writeln;
for i:=0 to n-1 do
begin
for j:=0 to newm-1 do
begin
ma[i][j]:=mabuf[i][j];
write(ma[i][j],' ');
end;
writeln;
end;
end.
Пример ввода:
2 2 2
1 2
1 -2
Пример вывода:
1 0 2
1 0 -2