Задание 1.
program z1;
var a: array[0..14] of integer;
i: integer;
begin
Randomize;
for i:=0 to 14 do a[i] := Random(101) - 50;
for i:=0 to 14 do write(a[i], ' ');
end.
Задание 2.
program z2;
var a, b, c: array[0..19] of integer;
for i:=0 to 19 do begin
a[i] := Random(21) - 10;
b[i] := Random(21) - 10;
c[i] := a[i] + b[i];
end;
for i:=0 to 19 do write(a[i], ' ');
writeln();
for i:=0 to 19 do write(b[i], ' ');
for i:=0 to 19 do write(c[i], ' ');
Задание 3.
program z3;
var a: array[0..19] of integer;
a[0] := 1;
a[1] := 1;
for i:=2 to 19 do begin
a[i] := a[i-1] + a[i-2];
Задача 1:
var a:array[1..15] of integer;
i:integer;
for i:=1 to length(a) do begin
a[i]:=random(-101)+50;
writeln('a[',i,']=', a[i]);
Задача 2:
var i:integer;
a:array[1..20] of integer;
b:array[1..20] of integer;
c:array[1..20] of integer;
a[i]:=random(-21)+10;
b[i]:=random(-21)+10;
c[i]:=a[i]+b[i];
write(a[i]:3, ' ');
for i:=1 to length(b) do write(b[i]:3, ' ');
for i:=1 to length(c) do write(c[i]:3, ' ');
Задача 3 (ряд Фибоначчи):
if i<=2 then a[i]:=1
else begin
a[i]:=a[i-2]+a[i-1];
write(a[i], ' ');
Задание 1.
program z1;
var a: array[0..14] of integer;
i: integer;
begin
Randomize;
for i:=0 to 14 do a[i] := Random(101) - 50;
for i:=0 to 14 do write(a[i], ' ');
end.
Задание 2.
program z2;
var a, b, c: array[0..19] of integer;
i: integer;
begin
Randomize;
for i:=0 to 19 do begin
a[i] := Random(21) - 10;
b[i] := Random(21) - 10;
c[i] := a[i] + b[i];
end;
for i:=0 to 19 do write(a[i], ' ');
writeln();
for i:=0 to 19 do write(b[i], ' ');
writeln();
for i:=0 to 19 do write(c[i], ' ');
end.
Задание 3.
program z3;
var a: array[0..19] of integer;
i: integer;
begin
a[0] := 1;
a[1] := 1;
for i:=2 to 19 do begin
a[i] := a[i-1] + a[i-2];
end;
for i:=0 to 19 do write(a[i], ' ');
end.
Задача 1:
var a:array[1..15] of integer;
i:integer;
begin
for i:=1 to length(a) do begin
a[i]:=random(-101)+50;
writeln('a[',i,']=', a[i]);
end;
end.
Задача 2:
var i:integer;
a:array[1..20] of integer;
b:array[1..20] of integer;
c:array[1..20] of integer;
begin
for i:=1 to length(a) do begin
a[i]:=random(-21)+10;
b[i]:=random(-21)+10;
c[i]:=a[i]+b[i];
write(a[i]:3, ' ');
end;
writeln();
for i:=1 to length(b) do write(b[i]:3, ' ');
writeln();
for i:=1 to length(c) do write(c[i]:3, ' ');
end.
Задача 3 (ряд Фибоначчи):
var i:integer;
a:array[1..20] of integer;
begin
for i:=1 to length(a) do begin
if i<=2 then a[i]:=1
else begin
a[i]:=a[i-2]+a[i-1];
end;
write(a[i], ' ');
end;
end.