Const m=100; var a:array[1..m] of integer; n,i,s:integer; begin writeln('Введите n<=100:'); readln(n); Randomize; for i:=1 to n do begin a[i]:=random(50); write(a[i]:4); end; writeln; s:=0; for i:=1 to n do if a[i]<n then s:=s+a[i]; writeln('s=',s); end.
Answers & Comments
Verified answer
Const m=100;var a:array[1..m] of integer;
n,i,s:integer;
begin
writeln('Введите n<=100:');
readln(n);
Randomize;
for i:=1 to n do
begin
a[i]:=random(50);
write(a[i]:4);
end;
writeln;
s:=0;
for i:=1 to n do
if a[i]<n then s:=s+a[i];
writeln('s=',s);
end.
Пример:
Введите n<=100:
10
2 25 36 36 35 3 1 20 37 32
s=6