mirror of https://github.com/01-edu/public.git
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
420 B
31 lines
420 B
package solutions |
|
|
|
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') |
|
} |
|
}
|
|
|