Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program fakhri;
- {$APPTYPE CONSOLE}
- uses
- windows,
- SysUtils;
- const n_max = 10;
- type matrix = array[1..n_max,1..n_max] of integer;
- procedure rus;
- begin
- setconsolecp(1251);
- setconsoleoutputcp(1251);
- end;
- procedure input_n_m(out n,m:shortint; out fl:boolean);
- begin
- fl:=true;
- readln(n);
- if (n>n_max) or (n<1) then
- fl:=false;
- readln(m);
- if ((m>n_max) or (m<1)) and (fl=true) then
- fl:=false;
- end;
- procedure input_matrix(const n,m:shortint; out a:matrix);
- var
- i,j:shortint;
- begin
- i:=0;
- while (i<n) do
- begin
- inc(i);
- j:=0;
- while (j<m) do
- begin
- inc(j);
- read(a[i,j]);
- end;
- readln;
- end;
- end;
- procedure analysis(const a,b:matrix; const n,m:shortint; out stolb:shortint; out fl1:boolean);
- var
- i,j:shortint;
- begin
- i:=0;
- fl1:=true;
- stolb:=-1;
- while (i<n) and (fl1=true) do
- begin
- inc(i);
- j:=0;
- while (j<m) and (fl1=true) do
- begin
- inc(j);
- if (a[i,j] <> b[i,j]) then
- begin
- stolb:=j;
- fl1:=false;
- end
- end;
- end;
- end;
- procedure zamena(const a:matrix; var b:matrix; const stolb:shortint; const n,m:shortint);
- var
- i:shortint;
- gg:shortint;
- begin
- i:=0;
- while (i<n) do
- begin
- inc(i);
- gg:=b[i,m];
- b[i,m]:=b[i,stolb];
- b[i,stolb]:=gg;
- end;
- end;
- procedure output(const n,m:shortint; const a:matrix);
- var
- i,j:shortint;
- begin
- for i:=1 to n do
- begin
- for j:=1 to m do
- begin
- write(a[i,j]:5,' ');
- end;
- writeln;
- end;
- writeln;
- end;
- var
- a,b:matrix;
- n,m,stolb:shortint;
- fl,fl1:boolean;
- begin
- rus;
- input_n_m(n,m,fl);
- if fl = false then
- begin
- writeln('Некорректное n или m');
- end
- else
- begin
- input_matrix(n,m,a);
- input_matrix(n,m,b);
- analysis(a,b,n,m,stolb,fl1);
- output(n,m,a);
- output(n,m,b);
- if (fl1 = false) then
- begin
- writeln('done');
- zamena(a,b,stolb,n,m);
- output(n,m,b)
- end
- else
- writeln('Равно.');
- end;
- readln;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement