Guest User

Untitled

a guest
Feb 19th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 0.92 KB | None | 0 0
  1. program lab_6;
  2. const nmax=20;
  3. type mas=array[1..nmax] of integer;
  4.      matrix=array[1..nmax] of mas;
  5. var a:matrix; b:mas; n,m,i,j:integer;
  6. procedure InPut(var A:matrix; n,m:integer);
  7. var i,j:integer;
  8. begin
  9.      writeln ('vvedite elementi');
  10.      For i:=1 to n do
  11.      For j:=1 to m do
  12.      Readln(A[i,j]);
  13. end;
  14.  
  15. procedure Inser(var A:matrix; n,m:integer);
  16. var  i,j,t,v,w: integer;
  17. begin
  18. i:=1;
  19.  repeat
  20.  i:=i+1;
  21.    for j:= 2 to m do begin
  22.      v := A[1,j];
  23.      w:=A[i,j];
  24.      t := j-1;
  25.      while (v<a[1,t]) and (t>0) do  begin
  26.        A[1,t+1]:=A[1,t];
  27.        A[i,t+1]:=A[i,t];
  28.        t:=t-1;
  29.        end;
  30.      A[1,t+1]:=v;
  31.      A[i,t+1]:=w;
  32.    end;
  33.  until i=n;
  34.  
  35.  for i:=1 to n do begin
  36.   for j:=1 to m do
  37.    write (a[i,j]:5);
  38.    writeln;
  39.   end;
  40.  end;
  41.  
  42. begin
  43. writeln('vvedite kolichestvo strok');
  44. read(n);
  45. writeln('vvedite kolichestvo stolbcov');
  46. read(m);
  47. InPut(a,n,m);
  48. Inser(a,n,m);
  49. readln;
  50. end.
Add Comment
Please, Sign In to add comment