Time Limit:1000MS  Memory Limit:65535K

题型: 编程题   语言: 无限制

描述

在那个风起云涌的SCAU ACM里,有两位人生赢家,他们分别是大洲Takio神和Blue神。      (尤其是blue神。)
由于这两位人生赢家代码能力强,才高八斗,学富五车,英俊潇洒,玉树临风,独步江湖,呼风唤雨,妹子纷至沓来。
而小邪由于太渣了,只能默默地帮他们记录下他们换了多少个妹子。
以上背景纯属题目需要,其实两位大神是很专情的。
终于有一天,小邪计算出他们身边妹子的总数n,想要给Takio神和Blue神。
但是Takio神和Blue神的邮箱是使用英文的,而小邪的英语又很渣,于是无法将n翻译成英语发过去。
但是,小邪想到了你——聪明的14级新生,向你寻求答案。 出题人:K·小邪

输入格式

第一行是一个整数t(t <= 100),代表样例个数
对于每个样例有一个整数n(0<=n<=2000000000)

输出格式

对于每个n,输出其英文表现形式,具体格式见样例输出

输入样例

4
5
121
1010
1008611

输出样例

five
one hundred and twenty-one
one thousand and ten
one million, eight thousand, six hundred and eleven

Hint

输出不一定符合英语规范,但是要符合Sample的规范
对于一个n>1000,若n%1000 >= 100(%代表取余操作)且不为0,且在n%1000对应的英文输出前(如果存在)用","相连而不是"and" 需要用到的英文单词为(不包括引号):
"zero","one","two","three","four","five","six","seven","eight","nine"
"ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"
"twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"
"hundred","thousand","million","billion"
分别代表
0,1,2,3,4,5,6,7,8,9
10,11,12,13,14,15,16,17,18,19
20,30,40,50,60,70,80,90
100,1000,1000000,1000000000
#include<stdio.h>
#include<string.h>
void go(void);
int a[],k,num;
int leap,leap1,leap2,leap3,leap4,leap5,leap6,leap7,leap8,leap9,leap10;
char str[][]=
{
"zero","one","two","three","four","five","six",
"seven","eight","nine","ten","eleven","twelve",
"thirteen","fourteen","fifteen","sixteen",
"seventeen","eighteen","nineteen","twenty"
}; int main()
{
int i,k,T; strcpy(str[],"thirty");
strcpy(str[],"forty");
strcpy(str[],"fifty");
strcpy(str[],"sixty");
strcpy(str[],"seventy");
strcpy(str[],"eighty");
strcpy(str[],"ninety");
scanf("%d",&T);
while(T--)
{
memset(a,,sizeof(a));
leap=leap1=leap2=leap3=leap4=leap5=leap6=leap7=leap8=leap9=leap10=;
scanf("%d",&num);
i=;
k=num;
if(num>&&num%>=) leap=;
while(k!=)
{
a[i++]=k%;
k=k/;
}
k=i-;
if(k==||k==) {printf("%s\n",str[num]);continue;}
if(k==) {if(num>&&num<=||num%==) printf("%s\n",str[num]);
else printf("%s-%s\n",str[num-num%],str[num%]);continue;}
go();
printf("\n"); }
return ;
}
void go(void)
{
int temp1,temp2,temp3; if(a[]) {printf("%s billion",str[a[]]);leap10=;}
if((leap&&k>=)||(leap10&&a[]!=)||(leap10&&a[]!=)||(leap10&&a[]!=)||(leap10&&a[]!=)||(leap10&&a[]!=)||(leap10&&a[]!=))
printf(", "); if(a[]) {printf("%s hundred",str[a[]]);leap9=;}
temp1=a[]*+a[];
if(leap9&&temp1!=) printf(" and ");
if(temp1!=)
{
if((temp1>&&temp1<=)||temp1%==) printf("%s",str[temp1]);
else printf("%s-%s",str[temp1-temp1%],str[temp1%]);
leap7=;
}
if(leap9||leap7) printf(" million");
if((leap&&k>=)||((leap9&&a[]!=)||(leap7&&a[]!=))||((leap9&&a[]!=)||(leap7&&a[]!=))||((leap9&&a[]!=)||(leap7&&a[]!=))) printf(", "); if(a[]) {printf("%s hundred",str[a[]]);leap6=;}
temp2=a[]*+a[];
if(leap6&&temp2!=) printf(" and ");
if(temp2!=)
{
if((temp2>&&temp2<=)||temp2%==) printf("%s",str[temp2]);
else printf("%s-%s",str[temp2-temp2%],str[temp2%]);
leap4=;
}
if(leap6||leap4) printf(" thousand");
if(leap) printf(", ");
if(a[]) {printf("%s hundred",str[a[]]);leap3=;}
temp3=a[]*+a[];
if((leap3&&temp3!=)||(a[]==&&temp3!=)) printf(" and ");
if(temp3!=)
{
if((temp3>&&temp3<=)||temp3%==) printf("%s",str[temp3]);
else printf("%s-%s",str[temp3-temp3%],str[temp3%]);
}
}

F Takio与Blue的人生赢家之战的更多相关文章

  1. JavaScript Array

    1.常用方法 // 数组构造 var a = new Array(20); // 长度为20的数组 var b = new Array('red', 'blue', 'white'); var c = ...

  2. iOS - 二维码扫描和应用跳转

    序言 前面我们已经调到过怎么制作二维码,在我们能够生成二维码之后,如何对二维码进行扫描呢? 在iOS7之前,大部分应用中使用的二维码扫描是第三方的扫描框架,例如ZXing或者ZBar.使用时集成麻烦, ...

  3. gradient color

    http://www.cnblogs.com/YouXianMing/p/3793913.html layer 不能自动autolay, 只能在viewDidLayout里面设置宽度 - (void) ...

  4. javaSE第二十五天

    第二十五天    399 1:如何让Netbeans的东西Eclipse能访问.    399 2:GUI(了解)    399 (1)用户图形界面    399 (2)两个包:    399 (3) ...

  5. C语言学习资料(转载)

    ◆经典C源程序100例:http://post.baidu.com/f?kz=8618367 ◆时钟的驻留程序:http://post.baidu.com/f?kz=10822377 ◆数据结构暨若干 ...

  6. UI:tomcat(说话小程序)、相框动画、UISgmentcontrol、UISwitch

    UISegmentedControl 分段控件 //1. UISegmentedControl 分段控件 (就是一个一个的按钮) //分段显示的标题是以一个数组存储的 NSArray * titles ...

  7. 《JavaScript高级程序设计》心得笔记-----第二篇章

    第五章 9.Function函数 1)         函数内部有两个特殊的对象: (1)       arguments(主要用于保存函数参数,有一个属性callee,这是一个指针,指向拥有argu ...

  8. JSF 2 radio buttons example

    In JSF, "h:selectOneRadio" tag is used to render a set of HTML input element of type " ...

  9. GUI编程笔记(java)08:GUI通过鼠标移动到按钮上更改背景色案例

    首先我们看看源代码如下: package cn.itcast_06; import java.awt.Button; import java.awt.Color; import java.awt.Fl ...

随机推荐

  1. editplus快捷键大全其他editplus快捷键

    editplus快捷键大全其他editplus快捷键,更多快捷键请参考以下文章:editplus快捷键大全之editplus搜索快捷键 editplus快捷键大全之editplus编辑快捷键 edit ...

  2. [Effective JavaScript 笔记]第6章:库和API设计--个人总结

    前言 又到了一章的总结,这章里的内容.是把我从一个代码的使用者,如何换位成一个代码的编写者.如何让别人用自己的代码更容易,不用去注意太多的无用细节,不用记住冗长的函数名.在使用API时怎样避免使用者会 ...

  3. python4delphi Python could not be properly initialized. We must quit.

    要用32位的DLL,不要用64位的dll Unable to load Python 2.7 dll with Delphi 2010 #6  Closed GoogleCodeExporter op ...

  4. 浅谈B树

    B树即二叉搜索树: 1.所有非叶子结点至多拥有两个儿子(Left和Right): 2.所有结点存储一个关键字: 3.非叶子结点的左指针指向小于其关键字的子树,右指针指向大于其关键字的子树: 如:    ...

  5. android获取手机信息大全

    IMEI号,IESI号,手机型号: private void getInfo() { TelephonyManager mTm = (TelephonyManager) getSystemServic ...

  6. shell脚本步骤调试

    第一种方式===> [root@localhost functions]# sh -x test.sh --check xx+ '[' --check '!=' -check ']'+ case ...

  7. 《C#高级编程》学习笔记------C#中的事件和委托

    本文转载自张子阳 目录 委托的作用 将方法绑定到委托 事件的来由 Observer设计模式 .Net Framework中的委托与事件   引言 委托 和 事件在 .Net Framework中的应用 ...

  8. PYTHON实现HTTP基本认证(BASIC AUTHENTICATION)

    参考: http://www.voidspace.org.uk/python/articles/authentication.shtml#id20 http://zh.wikipedia.org/wi ...

  9. 【动态规划】拦截导弹_dilworth定理_最长递增子序列

    问题 K: [动态规划]拦截导弹 时间限制: 1 Sec  内存限制: 256 MB提交: 39  解决: 10[提交][状态][讨论版] 题目描述 张琪曼:“老师,修罗场是什么?” 墨老师:“修罗是 ...

  10. codeforces 471B. MUH and Important Things 解题报告

    题目链接:http://codeforces.com/problemset/problem/471/B 题目意思:有 n 个 tasks,编号依次为 1 - n,每个 task 都有一定的难度值来评估 ...