- 题目
- 题解(152)
- 讨论(254)
- 排行
- 面经 new
描述
考试题目和要点:
1、中文大写金额数字前应标明“人民币”字样。中文大写金额数字应用壹、贰、叁、肆、伍、陆、柒、捌、玖、拾、佰、仟、万、亿、元、角、分、零、整等字样填写。
2、中文大写金额数字到“元”为止的,在“元”之后,应写“整字,如532.00应写成“人民币伍佰叁拾贰元整”。在”角“和”分“后面不写”整字。
3、阿拉伯数字中间有“0”时,中文大写要写“零”字,阿拉伯数字中间连续有几个“0”时,中文大写金额中间只写一个“零”字,如6007.14,应写成“人民币陆仟零柒元壹角肆分“。 4、10应写作“拾”,100应写作“壹佰”。例如,1010.00应写作“人民币壹仟零拾元整”,110.00应写作“人民币壹佰拾元整” 5、十万以上的数字接千不用加“零”,例如,30105000.00应写作“人民币叁仟零拾万伍仟元整”
输入描述:
输入一个double数
输出描述:
输出人民币格式
示例1
输入:151121.15输出:
人民币拾伍万壹仟壹佰贰拾壹元壹角伍分
示例2
输入:1010.00输出:
人民币壹仟零拾元整
while True: try: rmb = input().split(".") n = rmb[0] m = rmb[1] x = ["0","1","2","3","4","5","6","7","8","9"] y = ["零","壹","贰","叁","肆","伍","陆","柒","捌","玖"] z = ["元","拾","佰","仟","万","拾","佰","仟","亿","拾","佰","仟","万亿","拾","佰","仟"] t = ["角","分"] result_b = "" for i in range(len(m)): if m[i] == "0": continue b = y[int(m[i])] + t[i] result_b += b #print(result_b) result_a = "人民币" n = n[::-1] for i in range(len(n))[::-1]: if n[i] == '0': result_a+='零' else: result_a += (y[int(n[i])] + z[i]) s = result_a s = s.replace("人民币零","人民币") s = s.replace("壹拾","拾") if result_b: print(s + result_b) else: print(s + "整") except: break
标签:中文,转换,大写,result,壹仟,写作,人民币 From: https://www.cnblogs.com/zle1992/p/17520958.html