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.
25 lines
601 B
25 lines
601 B
package cap3
|
|
|
|
var _numberTexts = []string{
|
|
"zero", "one", "two", "three", "four",
|
|
"five", "six", "seven", "eight", "nine",
|
|
}
|
|
|
|
// Ex14NumInput 输入数字,输出英文
|
|
func Ex14NumInput(num uint64, callback func(str string)) {
|
|
digits := make([]uint8, 0, 20)
|
|
for i := num; i >= 1; i /= 10 {
|
|
digits = append(digits, uint8(i%10))
|
|
}
|
|
|
|
for i := len(digits) - 1; i >= 0; i-- {
|
|
callback(_numberTexts[digits[i]])
|
|
}
|
|
}
|
|
|
|
// Ex14StrInput 输入数字字符串,输出英文
|
|
func Ex14StrInput(num string, callback func(str string)) {
|
|
for _, char := range num {
|
|
callback(_numberTexts[char-48])
|
|
}
|
|
}
|
|
|