怎么制作网站论坛模板,培训网页设计吗,wordpress主题发布站源码,西安app网站开发题目描述
请将一个数字#xff0c;翻译成对应的英文。
输入
一个自然数 n。#xff08;0≤n≤2^31−1#xff09;
输出
输出这个数的英文#xff0c;最后不要有多余的空格。
输入样例#xff1a;
1111111111
输出样例#xff1a;
one billion one hundred and e…题目描述
请将一个数字翻译成对应的英文。
输入
一个自然数 n。0≤n≤2^31−1
输出
输出这个数的英文最后不要有多余的空格。
输入样例
1111111111
输出样例
one billion one hundred and eleven million one hundred and eleven thousand one hundred and eleven
代码实现
#includeiostream
#includecmath
using namespace std;
int list[4]{1000000000,1000000,1000,100};
char s[4][10]{billion,million,thousand,hundred};
void read_1(int n)
{switch(n){case 1:coutone ;break;case 2:couttwo ;break;case 3:coutthree ;break;case 4:coutfour ;break;case 5:coutfive ;break;case 6:coutsix ;break;case 7:coutseven ;break;case 8:couteight ;break;case 9:coutnine ;break;case 10:coutten ;break;case 11:couteleven ;break;case 12:couttwelve ;break;case 13:coutthirteen ;break;case 14:coutfourteen ;break;case 15:coutfifteen ;break;case 16:coutsixteen ;break;case 17:coutseventeen ;break;case 18:couteighteen ;break;case 19:coutnineteen ;break;default:break;}
}
void read_10(int n)
{int tn/10;if(t1){switch(t){case 2:couttwenty ;break;case 3:coutthirty ;break;case 4:coutforty ;break;case 5:coutfifty ;break;case 6:coutsixty ;break;case 7:coutseventy ;break;case 8:couteighty ;break;case 9:coutninty ;break; }n%10;read_1(n);}else read_1(n);
}
void Read(int n)
{if(n100){read_10(n);return;}int i0;while(n0i4){int tn/list[i];if(t0){Read(t);couts[i] ;}n%list[i];i;}if(i4n0){coutand ;read_10(n);}return;
}
int main()
{int n;cinn;Read(n);return 0;
}