TLama

Untitled

Mar 20th, 2013
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 1.05 KB | None | 0 0
  1. program Project1;
  2.  
  3. uses
  4.   SysUtils;
  5.  
  6. type
  7.   TMatrix = array[1..4, 1..4] of Integer;
  8.  
  9. var
  10.   I: Integer;
  11.   X: Integer;
  12.   Y: Integer;
  13.   CurSum: Integer;
  14.   MaxIdx: Integer;
  15.   MaxSum: Integer;
  16.   Matrices: array[1..3] of TMatrix;
  17. begin
  18.   Randomize;
  19.  
  20.   MaxIdx := 0;
  21.   MaxSum := 0;
  22.  
  23.   for I := 1 to 3 do
  24.   begin
  25.     CurSum := 0;
  26.  
  27.     for X := 1 to 4 do
  28.       for Y := 1 to 4 do
  29.       begin
  30.         Matrices[I][X, Y] := Random(101);
  31.         CurSum := CurSum + Matrices[I][X, Y];
  32.       end;
  33.  
  34.     if CurSum > MaxSum then
  35.     begin
  36.       MaxIdx := I;
  37.       MaxSum := CurSum;
  38.     end;
  39.  
  40.     for X := 1 to 4 do
  41.     begin
  42.       for Y := 1 to 4 do
  43.         Write(IntToStr(Matrices[I][X, Y]), ' ');
  44.       WriteLn;
  45.     end;
  46.     WriteLn;
  47.   end;
  48.  
  49.   WriteLn;
  50.   WriteLn('The biggest matrix is the ' + IntToStr(MaxIdx) + '. one. The sum ' +
  51.     'of this matrix is ' + IntToStr(MaxSum) + '.');
  52.   WriteLn;
  53.  
  54.   for X := 1 to 4 do
  55.   begin
  56.     for Y := 1 to 4 do
  57.       Write(IntToStr(Matrices[MaxIdx][X, Y]), ' ');
  58.     WriteLn;
  59.   end;
  60.  
  61.   ReadLn;
  62. end.
Advertisement
Add Comment
Please, Sign In to add comment