Примеры программ на языке QBASIC


REM Подсчет числа слов в строке
CLS
SPACE = 1: WORDS = 0
PRINT "Введите строку"
INPUT "", S$
LENS = LEN(S$)
IF LENS = 0 THEN GOTO RET
IF LEFT$(S$, 1) <> " " THEN SPACE = 0: WORDS = 1
FOR J = 2 TO LENS
  IF SPACE = 1 AND MID$(S$, J, 1) <> " " THEN SPACE = 0: WORDS = WORDS + 1
  IF SPACE = 0 AND MID$(S$, J, 1) = " " THEN SPACE = 1
NEXT J
RET:
  PRINT "Число слов в строке = "; WORDS
END