package main import ( "fmt" "strings" ) var ( hash = map[int]string{ 0: "", 1: "thousand", 2: "million", 3: "billion", } num = map[byte]string{ '1': "one", '2': "two", '3': "three", '4': "four", '5': "five", '6': "six", '7': "seven", '8': "eight", '9': "nine", } tens = map[string]string{ "10": "ten", "11": "eleven", "12": "twelve", "13": "thirteen", "14": "fourteen", "15": "fifteen", "16": "sixteen", "17": "seventeen", "18": "eighteen", "19": "nineteen", "2" : "twenty", "3" : "thirty", "4" : "forty", "5" : "fifty", "6" : "sixty", "7" : "seventy", "8" : "eighty", "9" : "ninety", "0": "", } ) func main() { str := "" fmt.Scan(&str) if len(str)% 3 != 0 { n := len(str) for i := 0; i < 3 - (n % 3); i++ { str = "0" + str } } ans := "" count := 0 for part := str[len(str)-3:]; len(str) != 0; str = str[:len(str)-3] { part = str[len(str)-3:] tmp := convert(part) ans = strings.Join([]string{tmp,hash[count],ans}, " ") count++ } fmt.Println(ans) } func convert(str string) string { res := "" if s, ok := num[str[0]]; ok { res += s + " hundred " if str[1:] != "00" { res += "and " } } if str[1] == '1' { res += tens[str[1:]] return res } res += tens[str[1:2]] if str[1] != '0' && str[2] != '0' { res += " " } return res + num[str[2]] }