You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

31 lines
418 B

package correct
import (
"sort"
"github.com/01-edu/z01"
)
func intToDigits(n int) (digits []int) {
for n > 0 {
if n == 0 {
digits = append(digits, 0)
} else {
digits = append(digits, n%10)
}
n /= 10
}
return
}
func PrintNbrInOrder(n int) {
if n == 0 {
z01.PrintRune('0')
return
}
digits := intToDigits(n)
sort.Ints(digits)
for _, i := range digits {
z01.PrintRune(rune(i) + '0')
}
}