//PascalABC.NET (версия 3.1, сборка 1196 от 09.03.2016) function Transpose(a: array[,] of integer): array[,] of integer; //Поворот на 90гр по часовой стрелке begin var m := Length(a, 0); var n := Length(a, 1); Result := new integer[n, m]; for var i := 0 to n-1 do begin for var j := 0 to m-1 do Result[i, j] := a[m-1-j, i]; end; end;
begin var n := ReadInteger('Введите n:'); //Заполнение матрицы NxN сл. числами и вывод на экран var a :=MatrixRandom(n, n); for var i:=0 to n-1 do begin for var j:=0 to n-1 do Print(a[i,j]); println; end; println;
Println('поворот влево на 90 гр'); var b := Transpose(a); b:=Transpose(b); b:=Transpose(b); for var i:=0 to n-1 do begin for var j:=0 to n-1 do Print(b[i,j]); println; end; println;
Println('поворот вправо на 90гр'); b := Transpose(a); for var i:=0 to n-1 do begin for var j:=0 to n-1 do Print(b[i,j]); println; end; println;
Println('поворот на 180 гр'); b := Transpose(a); b := Transpose(b); for var i:=0 to n-1 do begin for var j:=0 to n-1 do Print(b[i,j]); println; end; end.
Uses GraphABC; procedure Draw(x, y, l, u : Real; t : Integer);
procedure Draw2(Var x, y: Real; l, u : Real; t : Integer); begin Draw(x, y, l, u, t); x := x + l*cos(u); y := y - l*sin(u);end; begin if t > 0 then beginl := l/3;Draw2(x, y, l, u, t-1);Draw2(x, y, l, u+pi/3, t-1); Draw2(x, y, l, u-pi/3, t-1);Draw2(x, y, l, u, t-1);end else Line(Round(x), Round(y), Round(x+cos(u)*l), Round(y-sin(u)*l))end; begin SetWindowSize(425,500); SetWindowCaption('Фракталы: Снежинка Коха'); Draw(10, 354, 400, pi/3, 4);Draw(410, 354, 400, pi, 4); Draw(210, 8, 400, -pi/3, 4);end.
function
Transpose(a: array[,] of integer): array[,] of integer;
//Поворот на 90гр по часовой стрелке
begin
var m := Length(a, 0);
var n := Length(a, 1);
Result := new integer[n, m];
for var i := 0 to n-1 do begin
for var j := 0 to m-1 do
Result[i, j] := a[m-1-j, i];
end;
end;
begin
var n := ReadInteger('Введите n:');
//Заполнение матрицы NxN сл. числами и вывод на экран
var a :=MatrixRandom(n, n);
for var i:=0 to n-1 do begin
for var j:=0 to n-1 do
Print(a[i,j]);
println;
end;
println;
Println('поворот влево на 90 гр');
var b := Transpose(a);
b:=Transpose(b);
b:=Transpose(b);
for var i:=0 to n-1 do begin
for var j:=0 to n-1 do
Print(b[i,j]);
println;
end;
println;
Println('поворот вправо на 90гр');
b := Transpose(a);
for var i:=0 to n-1 do begin
for var j:=0 to n-1 do
Print(b[i,j]);
println;
end;
println;
Println('поворот на 180 гр');
b := Transpose(a);
b := Transpose(b);
for var i:=0 to n-1 do begin
for var j:=0 to n-1 do
Print(b[i,j]);
println;
end;
end.
procedure Draw(x, y, l, u : Real; t : Integer);
procedure Draw2(Var x, y: Real; l, u : Real; t : Integer);
begin
Draw(x, y, l, u, t);
x := x + l*cos(u);
y := y - l*sin(u);end;
begin
if t > 0 then
beginl := l/3;Draw2(x, y, l, u, t-1);Draw2(x, y, l, u+pi/3, t-1);
Draw2(x, y, l, u-pi/3, t-1);Draw2(x, y, l, u, t-1);end
else
Line(Round(x), Round(y), Round(x+cos(u)*l), Round(y-sin(u)*l))end;
begin
SetWindowSize(425,500);
SetWindowCaption('Фракталы: Снежинка Коха');
Draw(10, 354, 400, pi/3, 4);Draw(410, 354, 400, pi, 4);
Draw(210, 8, 400, -pi/3, 4);end.