uses newdelay,crt; const n=4; var i,j:byte; osszeg,index:array[1..n] of byte; matrix:array[1..n,1..n] of byte; procedure beolvasas; var k:byte; begin k:=1; randomize; For i:=1 to n do for j:=1 to n do matrix[i,j]:=random(30); For i:=1 to n do index[i]:=i; for i:=1 to n do begin for j:=1 to n do osszeg[k]:=osszeg[k]+matrix[i,j]; inc (k) end; procedure csere(var a,b:byte); var c:byte; begin c:=a; a:=b; b:=c; end; procedure rendezes2; begin for i:=1 to (n-1) do For j:=i to n do If osszeg [index[i]] > osszeg [osszeg[j]] then csere (index[i],index[j]); end; procedure kiiras; begin for i:=1 to n do begin For j:=i to n do write (matrix[index[i],j]); writeln end; readln; end; begin beolvasas; rendezes2; kiiras; end.