var A:array[1..100] of integer; n, i, Summ:integer; begin randomize; write('n = '); readln(n); Summ := 0; for i := 1 to n do begin A[i] := random(201) - 100; write(A[i], ' '); if A[i] > 0 then Summ := Summ + A[i]; end;
writeln; if Summ <> 0 then writeln('Summ = ', Summ) else writeln('Нет ни одного положительного элемента'); readln; end.
//вторая программа
var A:array[1..100] of integer; B:array[1..100] of real; n, i, Summ:integer; begin randomize; write('n = '); readln(n); Summ := 0; for i := 1 to n do begin A[i] := random(201) - 100; write(A[i], ' '); if A[i] mod 2 = 0 then B[i] := A[i] / 2 else B[i] := A[i]; end;
writeln; writeln; writeln('Result:'); for i := 1 to n do write(B[i], ' '); readln; end.
Program p1; Const N=10; Var A:array[1..N] of integer; proizvedenie,i:integer; Begin proizvedenie:=1; For i:= 1 to n do Begin A[i]:=random(101)-50; Write(A[i],' '); End; Writeln; For i:= 1 to n do If a[i]<0 then proizvedenie:=proizvedenie*A[i]; Writeln('Произведение = ', proizvedenie); End.
Program p2; Const N=10; Var A:array[1..N] of integer; kolvo,i:integer; Begin For i:= 1 to n do Begin A[i]:=random(101)-50; Write(A[i],' '); End; Writeln; For i:= 1 to n do If a[i] mod 3=0 then kolvo:=kolvo+1; Writeln('Кратных трём элементов ',kolvo, ' штук'); End.
var
A:array[1..100] of integer;
n, i, Summ:integer;
begin
randomize;
write('n = ');
readln(n);
Summ := 0;
for i := 1 to n do
begin
A[i] := random(201) - 100;
write(A[i], ' ');
if A[i] > 0 then
Summ := Summ + A[i];
end;
writeln;
if Summ <> 0 then
writeln('Summ = ', Summ)
else
writeln('Нет ни одного положительного элемента');
readln;
end.
//вторая программа
var
A:array[1..100] of integer;
B:array[1..100] of real;
n, i, Summ:integer;
begin
randomize;
write('n = ');
readln(n);
Summ := 0;
for i := 1 to n do
begin
A[i] := random(201) - 100;
write(A[i], ' ');
if A[i] mod 2 = 0 then
B[i] := A[i] / 2
else
B[i] := A[i];
end;
writeln;
writeln;
writeln('Result:');
for i := 1 to n do
write(B[i], ' ');
readln;
end.
Program p1;
Const N=10;
Var A:array[1..N] of integer;
proizvedenie,i:integer;
Begin
proizvedenie:=1;
For i:= 1 to n do
Begin
A[i]:=random(101)-50;
Write(A[i],' ');
End;
Writeln;
For i:= 1 to n do
If a[i]<0 then
proizvedenie:=proizvedenie*A[i];
Writeln('Произведение = ', proizvedenie);
End.
Program p2;
Const N=10;
Var A:array[1..N] of integer;
kolvo,i:integer;
Begin
For i:= 1 to n do
Begin
A[i]:=random(101)-50;
Write(A[i],' ');
End;
Writeln;
For i:= 1 to n do
If a[i] mod 3=0 then
kolvo:=kolvo+1;
Writeln('Кратных трём элементов ',kolvo, ' штук');
End.