LeetCode:Integer to English Words
某厂面试归来,发现自己落伍了!>>> 1、题目名称 Integer to English Words(按英语读法输出数字对应单词) 2、题目地址 https://leetcode.com/problems/integer-to-english-words/ 3、题目内容 英文:Convert a non-negative integer to its english words representation. Given input is guaranteed to be less than 231 - 1. 中文:给出一个非负整数,输出该数字在英语对应的单词,数字小于2^31-1 例如:下面是三个转换的例子 123 -> "One Hundred Twenty Three" 12345 -> "Twelve Thousand Three Hundred Forty Five" 1234567 -> "One Million Two Hundred Thirty Four Thousand Five Hundred Sixty Seven" 4、解题方法 其实一开始我把题目想复杂了。这道题不用考虑英语中隔位要写“And”的情况。如101,在英语中的念法为“One Hundred And One”,在这道题中,只需要输出“One Hundred One”就可以了。因此