äâóìåðíîì ìàññèâå âûáðàòü ýëåìåíòû, êîòîðûå áîëüøå ñóììû ýëåìåíòîâ ãëàâíîé äèàãîíàëè ìàññèâà.

 

 

Uses CRT;

 

Const N = 10;

      M = 100;

 

Var I,J,Sum : Integer;

    S : Array[1..N, 1..N] of Integer;

   

Begin

     ClrScr;

     Sum := 0;

     For I := 1 To N Do

         For J := 1 To N Do

             S[I, J] := Random(M);

            

     For I := 1 To N Do

         S[I,I] := Round (S[I,I]/N*2);

            

     For I := 1 To N Do

         Sum := Sum + S[I,I];

            

     For I := 1 To N Do

     Begin

         For J := 1 To N Do

         Begin

             TextColor(LightGray);

             If S[I,J] > Sum Then TextColor(Red);

             If I = J Then TextColor(Blue);

             Write(S[I,J]:3);

         End;

         WriteLn;

         TextColor(LightGray);

     End;

 

     WriteLn('Sum=',Sum);

 

     ReadLn;

End.