Advertisement
Guest User

Lab2

a guest
Apr 8th, 2020
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 2.45 KB | None | 0 0
  1. uses
  2.   System.SysUtils;
  3.  
  4.  
  5. var
  6.   matrix: array  of array of integer;
  7.   M, N, I, J, K, L : integer;
  8.  
  9. begin
  10. Write('M - ' );
  11. ReadLn(M);
  12.  
  13. Write('N - ' );
  14. ReadLn(N);
  15.  
  16. SetLength(matrix, M, N);
  17. WriteLn('1st task');
  18.   for i:=0 to M - 1 do
  19.   begin
  20.     for j:=0 to N - 1 do
  21.     begin
  22.       matrix[i][j]:= 10*i;
  23.       Write(' ', matrix[i][j]);
  24.       if j = N-1 then WriteLn;
  25.     end;
  26.   end;
  27.  
  28. {Присвоение каждому элементу матрицы значение 0, для корректной работы}
  29. for i:=0 to M - 1 do
  30.   begin
  31.     for j:=0 to N - 1 do
  32.     begin
  33.       matrix[i][j] := 0;
  34.     end;
  35.   end;
  36.  
  37.  
  38. WriteLn('2nd task');
  39.   for i:=0 to M - 1 do
  40.   begin
  41.     for j:=0 to N - 1 do
  42.     begin
  43.       matrix[j][i]:= 5*j;
  44.       Write(' ', matrix[j][i]);
  45.       if j = N-1 then WriteLn;
  46.     end;
  47.   end;
  48.  
  49. {Присвоение каждому элементу матрицы значение 0, для корректной работы}
  50. for i:=0 to M - 1 do
  51.   begin
  52.     for j:=0 to N - 1 do
  53.     begin
  54.       matrix[i][j] := 0;
  55.     end;
  56.   end;
  57.  
  58. WriteLn('3rd task');
  59.   for i:=0 to M - 1 do
  60.   begin
  61.     for j:=0 to N - 1 do
  62.     begin
  63.  
  64.       matrix[i][j]:= i + j;
  65.       Write(' ', matrix[i][j]);
  66.       if j = N-1 then WriteLn;
  67.     end;
  68.   end;
  69.  
  70. {Присвоение каждому элементу матрицы значение 0, для корректной работы}
  71. for i:=0 to M - 1 do
  72.   begin
  73.     for j:=0 to N - 1 do
  74.     begin
  75.       matrix[i][j] := 0;
  76.     end;
  77.   end;
  78.  
  79. WriteLn('4th task');
  80.   for i:=0 to M - 1 do
  81.   begin
  82.     for j:=0 to N - 1 do
  83.     begin
  84.  
  85.       matrix[i][j]:= i - j;
  86.       Write(' ', matrix[i][j]);
  87.       if j = N-1 then WriteLn;
  88.     end;
  89.   end;
  90. {Присвоение каждому элементу матрицы значение 0, для корректной работы}
  91. for i:=0 to M - 1 do
  92.   begin
  93.     for j:=0 to N - 1 do
  94.     begin
  95.       matrix[i][j] := 0;
  96.     end;
  97.   end;
  98.  
  99. WriteLn('5th task');
  100. Write('(1 < K < ', M , ' K = ');
  101. Read(K);
  102.  
  103. k:= k - 1;
  104.   for i:=0 to M - 1 do
  105.   begin
  106.     for j:=0 to N - 1 do
  107.     begin
  108.       {Заполнение матрицы числами i+1}
  109.       matrix[i][j]:= i + 1;
  110.  
  111.       if j = N - 1 then WriteLn;
  112.       if i - 1 = k then
  113.       begin
  114.         for L := 0 to N - 1  do
  115.         begin
  116.          Write(matrix[i - 1][l], ' ');
  117.           k:= k - 1;
  118.         end;
  119.  
  120.       end;
  121.     end;
  122.   end;
  123. ReadLn;
  124.  
  125. ReadLn;
  126. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement