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.

49 lines
665 B

package main
import (
"fmt"
"sort"
student "student"
"lib"
)
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 {
fmt.Print("0")
return
}
digits := intToDigits(n)
sort.Ints(digits)
for _, i := range digits {
fmt.Printf("%c", rune(i)+'0')
}
fmt.Println()
}
func main() {
table := append(
lib.MultRandIntBetween(0, lib.MaxInt),
lib.MaxInt,
321,
321321,
0,
)
for _, arg := range table {
lib.Challenge("PrintNbrInOrder", student.PrintNbrInOrder, printNbrInOrder, arg)
}
}