Program abra;
Var
X : Array [1..20, 1..20] Of
real;
N : Integer;
P : Real;
i, j: Integer;
begin
WriteLn ('Вычисление произведения ');
Write ('Введите размерность: N = ');
ReadLn (N);
WriteLn ('Введите элементы массива:');
For i := 1 To N Do
For j := 1 To N Do
Begin
Write ('X[', i, ',', j, '] = ');
ReadLn (X [i, j] );
End;
P := 1;
P := P * X [i, j];
if (X [i,j])=0 then writeln('присутствуют нулевые элементы') else
WriteLn ('Произведение: P = ',p: 6: 1);
readln;
end.
Объяснение:
1.
const N = 10;
var a: array [1..N] of integer;
i, x: integer;
write('Введите x: ');
readln(x);
for i := 1 to N do
a[i] := x + i - 1;
write(a[i], ' ');
end;
2.
i: integer;
a[1] := 1;
a[2] := 1;
for i := 3 to N do
a[i] := a[i-1] + a[i-2];
3.
const N = 6;
a[N] := 1;
for i := N-1 downto 1 do
a[i] := 2 * a[i+1];
Program abra;
Var
X : Array [1..20, 1..20] Of
real;
N : Integer;
P : Real;
i, j: Integer;
begin
WriteLn ('Вычисление произведения ');
Write ('Введите размерность: N = ');
ReadLn (N);
WriteLn ('Введите элементы массива:');
For i := 1 To N Do
For j := 1 To N Do
Begin
Write ('X[', i, ',', j, '] = ');
ReadLn (X [i, j] );
End;
P := 1;
For i := 1 To N Do
For j := 1 To N Do
P := P * X [i, j];
if (X [i,j])=0 then writeln('присутствуют нулевые элементы') else
WriteLn ('Произведение: P = ',p: 6: 1);
readln;
end.
Объяснение:
1.
const N = 10;
var a: array [1..N] of integer;
i, x: integer;
begin
write('Введите x: ');
readln(x);
for i := 1 to N do
begin
a[i] := x + i - 1;
write(a[i], ' ');
end;
end.
2.
const N = 10;
var a: array [1..N] of integer;
i: integer;
begin
a[1] := 1;
a[2] := 1;
for i := 3 to N do
begin
a[i] := a[i-1] + a[i-2];
end;
for i := 1 to N do
begin
write(a[i], ' ');
end;
end.
3.
const N = 6;
var a: array [1..N] of integer;
i, x: integer;
begin
a[N] := 1;
for i := N-1 downto 1 do
begin
a[i] := 2 * a[i+1];
end;
for i := 1 to N do
begin
write(a[i], ' ');
end;
end.