题解 | #人民币转换#
人民币转换
https://www.nowcoder.com/practice/00ffd656b9604d1998e966d555005a4b
s1,s2 = input().split('.')
string = '零壹贰叁肆伍陆柒捌玖拾'
#10000以内
def n2c(n):
m = int(n)
a = m//1000
b = (m%1000)//100
c = (m%100)//10
d = m%10
if a > 0:
res.append(string[a]+'仟')
elif a == 0 and n[0] == '0':
res.append('零')
if b > 0:
res.append(string[b]+'佰')
elif b == 0 and a != 0:
res.append('零')
if c > 0:
if b == 0 and c == 1:
res.append('拾')
else:
res.append(string[c]+'拾')
elif c == 0 and b != 0:
res.append('零')
if d > 0:
res.append(string[d])
res = ['人民币']
num1,num2 = int(s1),int(s2)
a = num1%10000
b = (num1//10000)%10000
c = num1//100000000
if c > 0:
n2c(str(c))
res.append('亿')
if b > 0:
n2c(str(b))
res.append('万')
if a > 0:
n2c(str(a))
res.append('元')
if num2 == 0:
res.append('整')
else:
if s2[0] == '0':
res.append(string[num2]+'分')
elif s2[1] == '0':
res.append(string[num2//10]+'角')
else:
res.append(string[num2//10]+'角'+string[num2%10]+'分')
print(''.join(res))
