Advertisement
Guest User

Untitled

a guest
Dec 18th, 2018
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 1.39 KB | None | 0 0
  1. program sdfdsf;
  2.  
  3. {$APPTYPE CONSOLE}
  4. uses
  5.   SysUtils;
  6.  
  7. var
  8. m:array [0..100,0..100] of integer;
  9. n,j,i,k,l,r,x, str:integer;
  10.  
  11. begin
  12. writeln('vvedite kol-vo strok: ');
  13. readln(str);
  14. writeln('vvedite kol-vo stolbtsov: ');
  15. readln(n);
  16. for i:=1 to str do
  17.   for j:=1 to n do
  18.     readln(m[i,j]);
  19.  
  20. writeln('Your matrix:');
  21.   for i:=1 to n do
  22.     begin
  23.       for j:=1 to n do
  24.         write(m[i,j]:3, '  ');
  25.       writeln;
  26.     end;
  27.  
  28. for i:=1 to str do
  29. begin
  30. L:=2;
  31. r:=n;
  32. k:=n;
  33. repeat
  34.   for j:=r downto l do
  35.     if m[i,j-1]<m[i,j] then
  36.       begin
  37.         x:=m[i,j-1];
  38.         m[i,j-1]:=m[i,j];
  39.         m[i,j]:=x;
  40.         k:=j;
  41.       end;
  42.  
  43.   L:=k+1;
  44.  
  45.     for j:=L to r do
  46.       if m[i,j-1]<m[i,j] then
  47.         begin
  48.           x:=m[i,j-1];
  49.           m[i,j-1]:=m[i,j];
  50.           m[i,j]:=x;
  51.           k:=j;
  52.         end;
  53.   r:=k-1;
  54. until l>r;
  55. end;
  56.  
  57. writeln;
  58. writeln('Shakernaya ubivanie po strokam:');
  59.  
  60. for i:=1 to str do
  61. begin
  62.   for j:=1 to n do
  63.     write(m[i,j]:4, '  ');
  64.   writeln;
  65.   end;
  66.  
  67.  
  68. for j:=1 to n do
  69.   for i:=2 to str do
  70.   begin
  71.     x:=m[i,j];
  72.     m[0,j]:=x;
  73.     k:=i;
  74.       while x<m[k-1,j] do
  75.         begin
  76.           m[k,j]:=m[k-1,j];
  77.           k:=k-1;
  78.  
  79.         end;
  80.         m[k,j]:=x;
  81.     end;
  82.  
  83. writeln('pryamoi vkluchenie stolbtsi::');
  84.  
  85. for i:=1 to str do
  86. begin
  87.   for j:=1 to n do
  88.     write(m[i,j]:4, '  ');
  89.   writeln;
  90.   end;
  91. readln;
  92. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement