Const n=6; var a:array[1..n,1..n]of integer; b:array[1..n]of integer; i,j:integer; begin for i:=1 to n do begin for j:=1 to n do begin a[i,j]:=random(100); write(a[i,j]:4); end; b[i]:=a[i,i]; writeln; end; writeln; for i:=1 to n do write(b[i]:4); end. вариант главной и побочной диагонали в одномерный массив const n=6; var a:array[1..n,1..n]of integer; b:array[1..n*2]of integer; i,j,k:integer; begin writeln; for i:=1 to n do begin for j:=1 to n do begin a[i,j]:=random(100); write(a[i,j]:4); end; k:=k+1; b[k]:=a[i,i]; k:=k+1; b[k]:=a[i,n+1-i]; writeln; end; writeln; for i:=1 to n*2 do write(b[i]:4); end.
n=6;
var
a:array[1..n,1..n]of integer;
b:array[1..n]of integer;
i,j:integer;
begin
for i:=1 to n do
begin
for j:=1 to n do
begin
a[i,j]:=random(100);
write(a[i,j]:4);
end;
b[i]:=a[i,i];
writeln;
end;
writeln;
for i:=1 to n do
write(b[i]:4);
end.
вариант главной и побочной диагонали в одномерный массив
const
n=6;
var
a:array[1..n,1..n]of integer;
b:array[1..n*2]of integer;
i,j,k:integer;
begin
writeln;
for i:=1 to n do
begin
for j:=1 to n do
begin
a[i,j]:=random(100);
write(a[i,j]:4);
end;
k:=k+1;
b[k]:=a[i,i];
k:=k+1;
b[k]:=a[i,n+1-i];
writeln;
end;
writeln;
for i:=1 to n*2 do
write(b[i]:4);
end.
x,y:real;
begin
x:=-1;
while x<=1 do begin
Writeln('x=',x:4:1,', y=',x*x*x:9:6);
x:=x+0.1
end
end.
Результат выполнения программы:
x=-1.0, y=-1.000000
x=-0.9, y=-0.729000
x=-0.8, y=-0.512000
x=-0.7, y=-0.343000
x=-0.6, y=-0.216000
x=-0.5, y=-0.125000
x=-0.4, y=-0.064000
x=-0.3, y=-0.027000
x=-0.2, y=-0.008000
x=-0.1, y=-0.001000
x= 0.0, y= 0.000000
x= 0.1, y= 0.001000
x= 0.2, y= 0.008000
x= 0.3, y= 0.027000
x= 0.4, y= 0.064000
x= 0.5, y= 0.125000
x= 0.6, y= 0.216000
x= 0.7, y= 0.343000
x= 0.8, y= 0.512000
x= 0.9, y= 0.729000
x= 1.0, y= 1.000000