جستجو باینری
CLS
INPUT "How many number : ", n
DIM a(n)
PRINT
PRINT "enter"; n; "number : ": PRINT
FOR i = 1 TO n
INPUT a(i)
NEXT
FOR i = 1 TO n - 1
FOR j = 1 TO n - i
IF a(j) > a(j + 1) THEN SWAP a(j), a(j + 1)
NEXT j, i
FOR i = 1 TO n
PRINT a(i);
NEXT i
PRINT : PRINT
INPUT "Enter search number : ", x
l = 1: h = n
WHILE h >= l
mi = INT((h + l) / 2)
IF a(mi) = x THEN PRINT "found your number in araye"; mi: END
IF a(mi) < x THEN
l = mi + 1
ELSE
h = mi - 1
END IF
WEND
PRINT "no found !!!"