1)
const
handsfree = false;
nmax = 50;
random_min = -50;
random_max = 50;
var
a: array[1..nmax] of real;
i, n: integer;
sum: real;
begin
{ввод массива}
n := nmax;
if handsfree then begin
for i := 1 to n do
a[i] := random(random_max - random_min) + random_min;
write(a[i], ' ');
end
else begin
readln(a[i]);
end;
writeln();
{подсчет суммы}
sum := 0;
sum := sum + sqr(a[i]);
writeln('L = ', sqrt(sum));
end.
2)
nmax = 10;
a: array[0..nmax] of real;
sum, x: real;
for i := 0 to n do
write('x = ');
readln(x);
sum := a[n];
for i := n - 1 downto 0 do
sum := sum * x + a[i];
writeln('S = ', sqrt(sum));
1)
const
handsfree = false;
nmax = 50;
random_min = -50;
random_max = 50;
var
a: array[1..nmax] of real;
i, n: integer;
sum: real;
begin
{ввод массива}
n := nmax;
if handsfree then begin
for i := 1 to n do
begin
a[i] := random(random_max - random_min) + random_min;
write(a[i], ' ');
end
end
else begin
for i := 1 to n do
readln(a[i]);
end;
writeln();
{подсчет суммы}
sum := 0;
for i := 1 to n do
sum := sum + sqr(a[i]);
writeln('L = ', sqrt(sum));
end.
2)
const
handsfree = false;
nmax = 10;
random_min = -50;
random_max = 50;
var
a: array[0..nmax] of real;
i, n: integer;
sum, x: real;
begin
{ввод массива}
n := nmax;
if handsfree then begin
for i := 0 to n do
begin
a[i] := random(random_max - random_min) + random_min;
write(a[i], ' ');
end
end
else begin
for i := 0 to n do
readln(a[i]);
end;
writeln();
{подсчет суммы}
write('x = ');
readln(x);
sum := a[n];
for i := n - 1 downto 0 do
sum := sum * x + a[i];
writeln('S = ', sqrt(sum));
end.
//For
Var
ar:array[1..5] of integer;
i:integer;
r:real;
begin
for i:=1 to 5 do
begin
readln(ar[i]);
r:=r+ar[i];
end;
r:=r/i;
writeln(r);
end.
//while
Var
ar:array[1..5] of integer;
i:integer;
r:real;
begin
while i<>5 do
begin
i:=i+1;
readln(ar[i]);
r:=r+ar[i];
end;
r:=r/i;
writeln(r);
end.
//repeat
Var
ar:array[1..5] of integer;
i:integer;
r:real;
begin
repeat
i:=i+1;
readln(ar[i]);
r:=r+ar[i];
until i=5;
r:=r/i;
writeln(r);
end.
Пример ввода:
1
2
1
2
1
Пример вывода:
1.4