Дана последовательность натуральных чисел. Определить одинаковые соседние числа, встречающиеся в последовательности, вывести их порядковые номера — Basic(Бейсик)

REM program
CLS
DIM numbers(1000)
enough = 1
count = 0
posCount = 0
offset = 1
i = 0
 
REM Entering of the sequence
PRINT "Enter the sequence of the numbers. To stop enter 0:"
WHILE enough <> 0
        count = count + 1
        INPUT "->", numbers(count)
        enough = numbers(count)
WEND
 
REM Find the task
WHILE offset < count
        IF numbers(offset) = numbers(offset - 1) THEN
                WHILE numbers(offset) = numbers(offset - 1)
                        posCount = posCount + 1
                        offset = offset + 1
                WEND
 
                PRINT "The number ", numbers(offset - posCount), " is in equal positions: "
                FOR i = offset - posCount TO offset
                        PRINT i - 1
                NEXT i
        END IF
        offset = offset + 1
        posCount = 0
 
WEND
 
END

Leave a Comment