#include <iostream>
using namespace std;
void cout4(int w)
{
switch(w){
case 0: cout<<"zero"<<endl;break;
case 1: cout<<"one"<<endl;break;
case 2: cout<<"two"<<endl;break;
case 3: cout<<"three"<<endl;break;
case 4: cout<<"four"<<endl;break;
case 5: cout<<"five"<<endl;break;
case 6: cout<<"six"<<endl;break;
case 7: cout<<"seven"<<endl;break;
case 8: cout<<"eight"<<endl;break;
case 9: cout<<"nine"<<endl;break;
case 10: cout<<"ten"<<endl;break;
case 11: cout<<"eleven"<<endl;break;
case 12: cout<<"twelve"<<endl;break;
case 13: cout<<"thirteen"<<endl;break;
case 14: cout<<"fourteen"<<endl;break;
case 15: cout<<"fifteen"<<endl;break;
case 16: cout<<"sixteen"<<endl;break;
case 17: cout<<"seventeen"<<endl;break;
case 18: cout<<"eighteen"<<endl;break;
case 19: cout<<"nineteen"<<endl;break;
case 20: cout<<"twenty"<<endl;break;}
}
void cout3(int x)
{
switch(x){
case 2: cout<<"twenty";break;
case 3: cout<<"thirty";break;
case 4: cout<<"forty";break;
case 5: cout<<"fifty";break;
case 6: cout<<"sixty";break;
case 7: cout<<"seventy";break;
case 8: cout<<"eighty";break;
case 9: cout<<"ninety";break;
}
}
void cout2(int y)
{
switch(y){
case 1: cout<<"one hundred" ;break;
case 2: cout<<"two hundred" ;break;
case 3: cout<<"three hundred";break;
case 4: cout<<"four hundred";break;
case 5: cout<<"five hundred";break;
case 6: cout<<"six hundred";break;
case 7: cout<<"seven hundred";break;
case 8: cout<<"eight hundred";break;
case 9: cout<<"nine hundred";break;
}
}
void cout1(int z)
{
switch(z){
case 1: cout<<"one thousand";break;
case 2: cout<<"two thousand";break;
case 3: cout<<"three thousand";break;
case 4: cout<<"four thousand";break;
case 5: cout<<"five thousand";break;
case 6: cout<<"six thousand";break;
case 7: cout<<"seven thousand";break;
case 8: cout<<"eight thousand";break;
case 9: cout<<"nine thousand";break;}
}
int main()
{
int n[10005],j=0,a,b,c,d;
while(cin>>n[j])
{
if(n[j]<0||n[j]>9999) break;
else if(n[j]>=0&&n[j]<=20)
cout4(n[j]);
else if(n[j]>20&&n[j]<100)
{
a=n[j]/10;b=n[j]-a*10;
if(b!=0){
cout3(a);
cout<<"-";
cout4(b);}
else{
cout3(a);
cout<<endl;}
}
else if(n[j]==100)
cout<<"one hundred"<<endl;
else if(n[j]>100&&n[j]<1000)
{
a=n[j]/100;b=(n[j]-a*100)/10;c=n[j]-a*100-b*10;
if(b==0&&c==0){
cout2(a);
cout<<endl;}
else if(b!=0&&c==0)
{
if(b>2){
cout2(a);
cout<<" and ";
cout3(b);
cout<<endl;}
else{
cout2(a);
cout<<" and ";
cout4(n[j]-a*100);
}
}
else if(b==0&&c!=0){
cout2(a);
cout<<" and ";
cout3(b);
cout4(c);
}
else{
if(b>=2){
cout2(a);
cout<<" and ";
cout3(b);
cout<<"-";
cout4(c);}
else
{
cout2(a);
cout<<" and ";
cout4(n[j]-a*100);
}
}}
else if(n[j]==1000)
cout<<"one thousand"<<endl;
else if(n[j]>1000&&n[j]<10000)
{
a=n[j]/1000;b=(n[j]-a*1000)/100;c=(n[j]-a*1000-b*100)/10;d=n[j]-a*1000-b*100-c*10;
if(b==0&&c==0&&d==0){
cout1(a);
cout<<endl;}
else if(b!=0&&c==0&&d==0){
cout1(a);
cout<<" and ";
cout2(b);
cout<<endl;}
else if(b==0&&c!=0&&d==0)
{
if(c>=2){
cout1(a);
cout<<" and ";
cout3(c);
cout<<endl;}
else{
cout1(a);
cout<<" and ten"<<endl;}
}
else if(b!=0&&c==0&&d!=0){
cout1(a);
cout<<" and ";
cout2(b);
cout<<" and ";
cout4(d);
}
else if(b!=0&&c!=0&&d==0){
if(c>=2){
cout1(a);
cout<<" and ";
cout2(b);
cout<<" and ";
cout3(c);
cout<<endl;}
else{
cout1(a);
cout<<" and ";
cout2(b);
cout<<" and ";
cout4(n[j]-a*1000-b*100);}
}
else if(b==0&&c==0&&d!=0){
cout1(a);
cout<<" and ";
cout4(n[j]-a*1000);
}
else if(b==0&&c!=0){
if(c>=2){
cout1(a);
cout<<" and ";
cout3(c);
cout<<"-";
cout4(d);}
else{
cout1(a);
cout<<" and ";
cout4(n[j]-a*1000);}
}
else
{
if(c>=2){
cout1(a);
cout<<" and ";
cout2(b);
cout<<" and ";
cout3(c);
cout<<"-";
cout4(d);}
else{
cout1(a);
cout<<" and ";
cout2(b);
cout<<" and ";
cout4(n[j]-a*1000-b*100);
}
}
}
j++;
}
return 0;
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
杭电ACM课件.rar (91个子文件)
杭电ACM课件
杭电ACM课件
(课件1)初识ACM_20070925_simple.rar 1.44MB
(课件9)二分图及其应用.rar 151KB
(课件4)动态规划(1)_20071024.rar 280KB
(课件5)动态规划(2).rar 145KB
并查集.rar 170KB
(课件8)搜索入门2.rar 163KB
(课件7)贪心算法.rar 154KB
(课件6)计算几何基础_20071030.rar 857KB
(课件10)母函数及其应用_new.rar 128KB
(lecture_11)组合博弈入门.rar 151KB
(课件2)老少皆宜数学题20071010.rar 322KB
(课件3)递推求解new.rar 206KB
(课件11)特殊的数.rar 1.16MB
HDU 解题报告
acm 1239.txt 726B
acm 2023.txt 1KB
G++ acm 1880.txt 700B
acm 2008.txt 297B
acm 2010.txt 545B
acm 1003.txt 466B
acm 2014.txt 515B
acm 2034.txt 903B
acm 1231.txt 1002B
acm 1860.txt 397B
acm 2000.txt 255B
acm 1084.txt 1KB
acm 2003.txt 160B
HDOJ+1465-1860
1555.cpp 246B
1597.cpp 404B
1732.cpp 4KB
1735.cpp 1KB
1753_1.cpp 5KB
1480.cpp 4KB
1715.cpp 285B
1702.cpp 1KB
1720.cpp 693B
1859.cpp 423B
1725.cpp 550B
1860_1.cpp 1KB
1860.cpp 539B
1727.cpp 2KB
1803.cpp 163B
1466.cpp 782B
1859_1.cpp 1KB
1797.cpp 1KB
1753.cpp 4KB
1465.cpp 318B
1804.cpp 746B
acm 1233.txt 801B
3HDU 2000-2099 解题报告.CHM 831KB
acm 1797.txt 798B
acm 1002.txt 899B
acm 2017.txt 554B
HDOJ+1871+-+2000
1894.cpp 1KB
1881.cpp 1KB
1871_3.cpp 667B
1874.cpp 1KB
1895.cpp 597B
1871.cpp 717B
1880.cpp 774B
1877.cpp 363B
1878.cpp 978B
1879.cpp 1KB
1875.cpp 2KB
1881_1.cpp 731B
1873.cpp 2KB
2000.cpp 272B
1872.cpp 827B
1873_1.cpp 2KB
1878_2.cpp 1KB
1871_2.cpp 676B
1871_1.cpp 2KB
1874_1.cpp 2KB
1875_1.cpp 3KB
1939.cpp 353B
1875_2.cpp 1KB
acm 1725.txt 483B
acm 1878.txt 861B
acm 1881.txt 641B
acm 2020.txt 517B
acm 2011.txt 344B
acm 2025.txt 338B
acm 2002.txt 186B
acm 2001.txt 256B
acm 2031.txt 365B
acm 1727.txt 5KB
1224.txt 3KB
acm 2005.txt 1KB
acm 1228.txt 1KB
acm 2012.txt 575B
acm 2018.txt 361B
acm 1232.txt 509B
共 91 条
- 1
资源评论
- yunhua1002013-09-09内容还行,适合初学者使用。。。
- 断水流大师兄2013-04-04很有帮助,内容丰富
kangjie777
- 粉丝: 2
- 资源: 5
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功