Advertisement
Guest User

Lab2

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