1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | cls input "razmernost massiva"; n dim a(n) for i = 1 to n cls ? "a(";i;")="; input a(i) next i cls max = a(i) for i= 1 to n if max<a(i) then max=a(i) next i for i = 1 to n if max=a(i) then s=s+ 1 next i if s= 1 then goto 5 if s> 1 then goto 1 5 for i = 1 to n if max=a(i) then l=i next i for i = 1 to l- 1 if a(i) mod 2 = 0 then s=s+a(i) next i for i=l+ 1 to n if a(i) mod 2 = 0 then sum=sum+a(i) next i if s>sum then ? max end 1 input "max elementov neskolko, kekoy vy xotite ispolzovat"; g for i = 1 to n if a(i)=max then k=K+ 1 if a(i)=max and k=g then p=i: end for next i for i = 1 to p- 1 if a(i) mod 2 = 0 then s=s+a(i) next i for i=p+ 1 to n if a(i) mod 2 = 0 then sum=sum+a(i) next i if s>sum then ? max |
Тестирование выполнено в программе QB64 ( Скачать )