CLS
maxchislo = 2147483647
DIM b$(255)
DO
PRINT "Nakhozhdenie maksimalnoi tsifri i postroenie minimalnogo chisla"
PRINT "iz tsifr iskhodnogo chisla"
10 INPUT "Vvedite naturalnoe chislo:", a$
f = 0
k = 0
FOR i = 1 TO LEN(a$)
k = k + 1
b$(k) = MID$(a$, i, 1)
IF b$(k) < "0" OR b$ > "9" THEN f = 1
NEXT
IF f = 0 AND VAL(a$) > maxchislo THEN f = 1
IF f = 1 THEN PRINT "Vi vveli otritsatelnoe chislo ili desyatichnuyu drob."
IF f = 1 THEN PRINT "Povtorite vvod."
IF f = 1 THEN GOTO 10
LOOP UNTIL f = 0
max$ = b$(1)
kol = 1
FOR i = 2 TO k
IF b$(i) = max$ THEN kol = kol + 1
IF b$(i) > max$ THEN max$ = b$(i): kol = 1
NEXT
PRINT "Maksimalnaya tsifra="; max$
PRINT "Ona vstrechalas"; kol; "raz"
FOR i = 1 TO k
FOR j = 2 TO k
IF b$(j) < b$(j - 1) THEN SWAP b$(j), b$(j - 1)
NEXT
NEXT
FOR i = 1 TO k
c$ = c$ + b$(i)
NEXT
PRINT "Minimalnoe chislo:"; VAL(c$)
Тестирование выполнено в программе QB64 ( Скачать )