Var ar:array[1..n] of integer; sum,i:integer; begin randomize; writeln('First array:'); for i:=1 to n do begin ar[i]:=random(-50,50); write(ar[i]:4); sum:=sum+ar[i]; end; writeln; writeln('Sum=',sum); writeln('Final array:'); for i:=1 to n do begin ar[i]:=ar[i]*5; write(ar[i]:6); end; end.
Пример работы программы: First array: 24 45 28 40 -48 -7 29 43 -23 18 Sum=149 Final array: 120 225 140 200 -240 -35 145 215 -115 90
Var ar:array[1..n] of integer; sum,i:integer; begin randomize; writeln('First array:'); for i:=1 to n do begin ar[i]:=random(2,23); write(ar[i]:4); sum:=sum+sqr(ar[i]); end; writeln; writeln('Sum=',sum); writeln('Final array:'); for i:=1 to n do begin ar[i]:=ar[i]+ar[n]; write(ar[i]:4); end; end.
Пример работы программы: First array: 19 21 10 13 7 13 9 2 22 20 10 7 17 7 22 Sum=3229 Final array: 41 43 32 35 29 35 31 24 44 42 32 29 39 29 44
Const
n=10;
Var
ar:array[1..n] of integer;
sum,i:integer;
begin
randomize;
writeln('First array:');
for i:=1 to n do
begin
ar[i]:=random(-50,50);
write(ar[i]:4);
sum:=sum+ar[i];
end;
writeln;
writeln('Sum=',sum);
writeln('Final array:');
for i:=1 to n do
begin
ar[i]:=ar[i]*5;
write(ar[i]:6);
end;
end.
Пример работы программы:
First array:
24 45 28 40 -48 -7 29 43 -23 18
Sum=149
Final array:
120 225 140 200 -240 -35 145 215 -115 90
Const
n=15;
Var
ar:array[1..n] of integer;
sum,i:integer;
begin
randomize;
writeln('First array:');
for i:=1 to n do
begin
ar[i]:=random(2,23);
write(ar[i]:4);
sum:=sum+sqr(ar[i]);
end;
writeln;
writeln('Sum=',sum);
writeln('Final array:');
for i:=1 to n do
begin
ar[i]:=ar[i]+ar[n];
write(ar[i]:4);
end;
end.
Пример работы программы:
First array:
19 21 10 13 7 13 9 2 22 20 10 7 17 7 22
Sum=3229
Final array:
41 43 32 35 29 35 31 24 44 42 32 29 39 29 44