Problem Description
How many problems did you AC?
When you read this problem, don’t hasty and careless, this is also simple, haha, I didn’t cheat you.
The game over soon, WisKey starts using English begin countdown. He not only have no gene in math, but also bad in English. Fortunately, He met you who have gift in programming. So please help him to translate. 
 
Input
Give you an integer T, output T in English, and note that all of words are lower case. (0<=T<=9999)
 
Output
One answer One line.
Details see sample.
 
Sample Input
2034
1234
123
24
0
 
Sample Output
two thousand and thirty-four
one thousand and two hundred and thirty-four
one hundred and twenty-three
twenty-four
zero
 
 #include <stdio.h>
#include <string.h> int main(){
int number;
int a;
int b;
int c;
char digit[][];
char ten[][];
int flag=; strcpy(digit[],"zero");
strcpy(digit[],"one");
strcpy(digit[],"two");
strcpy(digit[],"three");
strcpy(digit[],"four");
strcpy(digit[],"five");
strcpy(digit[],"six");
strcpy(digit[],"seven");
strcpy(digit[],"eight");
strcpy(digit[],"nine");
strcpy(digit[],"ten");
strcpy(digit[],"eleven");
strcpy(digit[],"twelve");
strcpy(digit[],"thirteen");
strcpy(digit[],"fourteen");
strcpy(digit[],"fifteen");
strcpy(digit[],"sixteen");
strcpy(digit[],"seventeen");
strcpy(digit[],"eighteen");
strcpy(digit[],"nineteen");
strcpy(digit[],"twenty"); strcpy(ten[],"twenty");
strcpy(ten[],"thirty");
strcpy(ten[],"forty");
strcpy(ten[],"fifty");
strcpy(ten[],"sixty");
strcpy(ten[],"seventy");
strcpy(ten[],"eighty");
strcpy(ten[],"ninety"); while(scanf("%d",&number)!=EOF){
a=number/;
b=number/%;
c=number%; if(a!=){ //当千位不为0时才打印
flag=;
printf("%s thousand",digit[a]); if(b!= || c!=) //后面不为0才打印"and"
printf(" and ");
} if(b!=){
flag=;
printf("%s hundred",digit[b]); if(c!=)
printf(" and ");
} if(c<=){
if(flag== && c==) //前面已经打印,此时的0不打印
; else if(flag== && c==) //前面没有打印,此时的0打印
printf("zero"); else
printf("%s",digit[c]); //不为0直接打印
} else{
printf("%s",ten[c/]); //打印十位数 if(c%!=) //如果还有个位数,打印"-"和个位数
printf("-%s",digit[c%]);
} printf("\n"); } return ;
}

Hastiness的更多相关文章

随机推荐

  1. sql操作table

    1.增加表字段 alter table tbsptrustquotdoc(表名)  add  chargeapplystate(字段名) char(1)(类型) default '1'(默认值) 2. ...

  2. [原创]Devexpress XtraReports 系列 7 创建Drill-Down(向下钻取)报表

    昨天发表了Devexpress XtraReports系列第六篇[原创]Devexpress XtraReports 系列 6 创建并排报表,今天我们继续. 今天的主题是创建Drill-Down报表. ...

  3. poj 3216 Repairing Company(最短路Floyd + 最小路径覆盖 + 构图)

    http://poj.org/problem?id=3216 Repairing Company Time Limit: 1000MS   Memory Limit: 131072K Total Su ...

  4. UVaLive 6697 Homework Evaluation (DP)

    题意:给出一个长字符串,再给一个短字符串,进行匹配,如果第i个恰好匹配,则 +8,:如果不匹配,可以给长或短字符串添加-,先后匹配,这样-3, 连续的长字符串添加-,需要减去一个4:也可不给添加-,则 ...

  5. CGI 是什么

    CGI是公共网关接口,是Java Servlet 的前身,Java Servlet  是运行在服务器端的小程序.

  6. UI进阶 地图

    一.地图的简介 在移动互联网时代,移动app能解决用户的很多生活琐事,比如    导航:去任意陌生的地方    周边:找餐馆.找酒店.找银行.找电影院    手机软件:微信摇一摇.QQ附近的人.微博. ...

  7. 浏览器判断及IE版本区分

    备注:在火狐下和IE下,js的执行不一致,很多语句结果不一致,其他浏览器也可能,注意验证,多用if else包括window.onload: ①只用来区分IE和非IE内核的浏览器,由于只有IE支持Ac ...

  8. C:函数

    函数 函数:都是实现一定的功能.具有特定功能的代码段.凡是由系统提供的函数就是库函数,自己写的函数就是自定义函数. 如何定义一个函数  :  函数类型修饰符  函数名 (函数参数)  {  函数语句 ...

  9. 7. 泛化(Generalization)

    什么是泛化关系?用一个例子简单的说:假设A是B和C的父类,B.C具有公共类(父类)A,说明A是B.C的一般化(概括,也称泛化),B.C是A的特殊化. 在编程上,泛化关系(Generalization) ...

  10. Windows转到linux中,文件乱码,文件编码转换

    最近,学习又重新开始Linux学习,所以一直在Centos中,昨天一朋友把他在Windows下写的C程序发给我,我欣然答应,本以为很快就能在我的Linux系统中运行起来.没想到出现了乱码,结果想把这个 ...