首页 > 试题广场 >

学英语

[编程题]学英语
  • 热度指数:125797 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 32M,其他语言64M
  • 算法知识视频讲解
\hspace{15pt}你需要编写一个程序,使得对于输入的整数,输出其对应的英文单词。

\hspace{15pt}具体地,规则如下:
{\hspace{20pt}}_\texttt{1.}\,三位数字看成一整体,每三位数后添加一个计数单位,从小到大依次为 thousand(千)、million(百万);
{\hspace{20pt}}_\texttt{2.}\,对于百万以下、千以上的数字,通用公式为 x \textrm{ thousand } y ,其中 xy 代表数字;
{\hspace{20pt}}_\texttt{3.}\,对于百万以上的数字,通用公式为 x \textrm{ million } y \textrm{ thousand } z ,其中 xyz 代表数字;
{\hspace{20pt}}_\texttt{4.}\,每三位数内部,十位和个位之间,需要添加 and ;特别地,若百位为 0 ,则不添加。例如,1\,234 的英文为 one thousand two hundred and thirty four ,1\,034 的英文为 one thousand thirty four 。

\hspace{15pt}让我们再来看几个例子:
\hspace{23pt}\bullet\,22:twenty two ;
\hspace{23pt}\bullet\,100:one hundred
\hspace{23pt}\bullet\,145:one hundred and forty five ;
\hspace{23pt}\bullet\,1\,234:one thousand two hundred and thirty four ;
\hspace{23pt}\bullet\,8\,088:eight thousand eighty eight ;
\hspace{23pt}\bullet\,486\,669:four hundred and eighty six thousand six hundred and sixty nine ;
\hspace{23pt}\bullet\,1\,652\,510:one million six hundred and fifty two thousand five hundred and ten 。

输入描述:
\hspace{15pt}在一行上输入一个整数 n \left(1 \leqq n \leqq 2 \times 10^6\right) 代表待转换的整数。


输出描述:
\hspace{15pt}输出若干个小写的英文单词,代表转换后的结果。
示例1

输入

22

输出

twenty two
示例2

输入

2000000

输出

two million

这道题你会答吗?花几分钟告诉大家答案吧!