CLS
INPUT " vvedite N ", n
DIM a(n)
PRINT " vvedite massiv"
FOR i = 1 TO n
INPUT a(i)
NEXT
PRINT " massiv"
FOR i = 1 TO n
PRINT a(i);
NEXT
PRINT
k1 = 1
k2 = 1
FOR i = 2 TO n
IF a(i) < a(i - 1) THEN k1 = 1 ELSE k1 = k1 + 1: IF k1 > max1 THEN max1 = k1
IF a(i) > a(i - 1) THEN k2 = 1 ELSE k2 = k2 + 1: IF k2 > max2 THEN max2 = k2
NEXT
IF max1 >= max2 THEN max = max1 ELSE max = max2
PRINT "max dlina="; max
k1 = 1
k2 = 1
FOR i = 2 TO n
IF a(i) < a(i - 1) THEN k1 = 1 ELSE k1 = k1 + 1: IF k1 = max THEN kolp = kolp + 1
IF a(i) > a(i - 1) THEN k2 = 1 ELSE k2 = k2 + 1: IF k2 = max THEN kolp = kolp + 1
NEXT
PRINT "posledovatelnost";
IF kolp > 1 THEN PRINT "i"
PRINT
k1 = 1
k2 = 1
FOR i = 2 TO n
IF a(i) < a(i - 1) THEN k1 = 1 ELSE k1 = k1 + 1: IF k1 = max THEN FOR j = i - max + 1 TO i: PRINT a(j);: NEXT: PRINT
IF a(i) > a(i - 1) THEN k2 = 1 ELSE k2 = k2 + 1: IF k2 = max THEN FOR j = i - max + 1 TO i: PRINT a(j);: NEXT: PRINT
NEXT
Тестирование выполнено в программе QB64 ( Скачать )