from random import randint A = [randint (10,121) for i in range (14)] b = max(A) k = 0 print(A) l = 0 while k < 14: if A[k] != b: A.remove(A[k]) l = l + 1 else: break f = 0 for k in range (14 - l): f = A[k] + f print(f)
const n=15; var a: array[1..n] of integer; s,max: integer; k,i: byte; begin randomize; max:=0; s:=0; for i:=1 to n do begin a[i]:=random(10,120); write (a[i]:4); if a[i] > max then begin max:=a[i]; k:=i end end; for i:=k to n do s:=s+a[i]; writeln; writeln ('Максимальный элемент = ',max); writeln ('Сумма от максимального = ',s); end.
A = [randint (10,121) for i in range (14)]
b = max(A)
k = 0
print(A)
l = 0
while k < 14:
if A[k] != b:
A.remove(A[k])
l = l + 1
else:
break
f = 0
for k in range (14 - l):
f = A[k] + f
print(f)
var
a: array[1..n] of integer;
s,max: integer;
k,i: byte;
begin
randomize;
max:=0; s:=0;
for i:=1 to n do begin
a[i]:=random(10,120);
write (a[i]:4);
if a[i] > max
then begin max:=a[i]; k:=i end
end;
for i:=k to n do
s:=s+a[i];
writeln;
writeln ('Максимальный элемент = ',max);
writeln ('Сумма от максимального = ',s);
end.
Пример:
15 27 27 26 74 66 23 61 119 93 57 92 35 61 113
Максимальный элемент = 119
Сумма от максимального = 570