题解 | #学英语#
学英语
https://www.nowcoder.com/practice/1364723563ab43c99f3d38b5abef83bc
# 20240918
num1 = ['zero','one','two','three','four','five','six','seven','eight','nine','ten','eleven','twelve','thirteen','fourteen','fifteen','sixteen','seventeen','eighteen','nineteen']
num2 = [0,0,'twenty','thirty','forty','fifty','sixty','seventy','eighty','ninety']
def f100(n):
if n > 0:
if n < 20:
word.append(num1[n])
else:
word.append(num2[n//10])
if n%10 != 0:
word.append(num1[n%10])
def f1000(n):
if n >= 100:
word.append(num1[n//100])
word.append('hundred')
if n%100 != 0:
word.append('and')
f100(n%100)
while True:
try:
n = int(input())
except:
break
else:
word = []
a = n%1000
b = (n//1000)%1000
c = (n//1000000)%1000
d = (n//1000000000)%1000
if d > 0:
f1000(d)
word.append('billion')
if c > 0:
f1000(c)
word.append('million')
if b > 0:
f1000(b)
word.append('thousand')
if a > 0:
f1000(a)
print(*word)



