题解 | #学英语#
学英语
https://www.nowcoder.com/practice/1364723563ab43c99f3d38b5abef83bc
s=input() a="" for i in range(1,len(s)+1): if (i-1)%3==0 and i!=1: a=a+"," a=a+s[-i] s=a[::-1] n=s.split(",") num1 = ["","one","two","three","four","five","six","seven","eight","nine","ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen","twenty"] num2 = ["","","twenty","thirty","forty", "fifty","sixty","seventy","eighty","ninety"] num3 = ["","thousand","million","billion"] def f(n): if int(n)<100: if int(n)==0: return elif int(n)<21: return num1[int(n)] else: if int(n[-1])!=0: return num2[int(n[-2])]+" "+num1[int(n[-1])] else: return num2[int(n[-2])] else: if int(n[1:])==0: return num1[int(n[-3])]+" "+"hundred" elif int(n[-2])<2: return num1[int(n[-3])]+" "+"hundred"+" and "+num1[int(n[1:])] else: return num1[int(n[-3])]+" "+"hundred"+" and "+num2[int(n[-2])]+" "+num1[int(n[-1])] for i in range(len(n)): print(f(n[i])+" "+num3[len(n)-i-1],end=" ")