{ matica_otoc.pas Copyright (c) TrSek alias Zdeno Sekerak } { Program otoci stvorcovu maticu o 90 stupnov. } { } { Datum:23.03.2016 http://www.trsek.com } program matica_otoc; var mat: array[1..20,1..20] of integer; rozmer: integer; x,y: integer; zal: integer; begin writeln('Program otoci stvorcovu maticu o 90 stupnov.'); write('Zadaj rozmer matice = '); readln(rozmer); { nacita maticu } for y:=1 to rozmer do for x:=1 to rozmer do begin write('mat[',x,',',y,']='); readln(mat[x,y]); end; { otoci maticu } for y:=1 to rozmer div 2 do begin for x:=y to rozmer-y do begin { zaloha } zal:=mat[x,y]; { vymena v kruhu } mat[x,y] := mat[y,rozmer-x+1]; mat[y,rozmer-x+1] := mat[rozmer-x+1,rozmer-y+1]; mat[rozmer-x+1,rozmer-y+1] := mat[rozmer-y+1,x]; mat[rozmer-y+1,x] := zal; end; end; { vypise maticu } writeln('Matica otocena o 90 stupnov'); for y:=1 to rozmer do for x:=1 to rozmer do begin if(x=1)then write('|'); { vypise cislo } write(mat[x,y]:2); if(x<>rozmer)then write(', '); if(x= rozmer)then writeln('|'); end; { pocka na enter } readln; end.