A program that calculates how to break down a given sum into specific ticket denominations. The program uses denominations of 500, 100, 10, and 2 rubles. It validates that the sum can be broken down exactly (checking if change in 1 ruble is needed) and then calculates the number of each denomination required.
DIM tickets%(1 TO 4)
tickets%(1) = 500
tickets%(2) = 100
tickets%(3) = 10
tickets%(4) = 2
DIM numtickets%(1 TO 4)
INPUT "Введите сумму, которую надо разменять: ", summ
IF FIX(summ / tickets%(4)) * tickets%(4) < summ THEN
PRINT "У меня нет сдачи в 1 рубль!"
END
END IF
FOR i = 1 TO 4
numtickets%(i) = FIX(summ / tickets%(i))
summ = summ - tickets%(i) * numtickets%(i)
NEXT i
FOR i = 1 TO 4
PRINT numtickets%(i); " купюр по "; tickets%(i); "рублей"
NEXT i
END