Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program Project1;
- uses
- SysUtils;
- type
- TMatrix = array[1..4, 1..4] of Integer;
- var
- I: Integer;
- X: Integer;
- Y: Integer;
- CurSum: Integer;
- MaxIdx: Integer;
- MaxSum: Integer;
- Matrices: array[1..3] of TMatrix;
- begin
- Randomize;
- MaxIdx := 0;
- MaxSum := 0;
- for I := 1 to 3 do
- begin
- CurSum := 0;
- for X := 1 to 4 do
- for Y := 1 to 4 do
- begin
- Matrices[I][X, Y] := Random(101);
- CurSum := CurSum + Matrices[I][X, Y];
- end;
- if CurSum > MaxSum then
- begin
- MaxIdx := I;
- MaxSum := CurSum;
- end;
- for X := 1 to 4 do
- begin
- for Y := 1 to 4 do
- Write(IntToStr(Matrices[I][X, Y]), ' ');
- WriteLn;
- end;
- WriteLn;
- end;
- WriteLn;
- WriteLn('The biggest matrix is the ' + IntToStr(MaxIdx) + '. one. The sum ' +
- 'of this matrix is ' + IntToStr(MaxSum) + '.');
- WriteLn;
- for X := 1 to 4 do
- begin
- for Y := 1 to 4 do
- Write(IntToStr(Matrices[MaxIdx][X, Y]), ' ');
- WriteLn;
- end;
- ReadLn;
- end.
Advertisement
Add Comment
Please, Sign In to add comment