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. CF160D

    题意:给你一个图,判断每条边是否在最小生成树MST上,不在输出none,如果在所有MST上就输出any,在某些MST上输出at least one: 分析:首先必须知道在最小生成树上的边的权值一定是等 ...

  2. POJ 1584 A Round Peg in a Ground Hole(判断凸多边形,点到线段距离,点在多边形内)

    A Round Peg in a Ground Hole Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 4438   Acc ...

  3. OC动态特性

    今天是2.15周日,快要过年了,我以一个实习生的身份在公司工作了快要两个月了吧,什么是北漂,北漂就是感觉生活节奏变了,以前困了可以上课睡觉,累了可以回家休息数周,人际交往乏了,可以躲起来看着窗外的雨或 ...

  4. 结构类模式(六):享元(Flyweight)

    定义 运用共享技术有效的支持大量细粒度的对象. 两个状态 内蕴状态存储在享元内部,不会随环境的改变而有所不同,是可以共享的. 外蕴状态是不可以共享的,它随环境的改变而改变的,因此外蕴状态是由客户端来保 ...

  5. Oracle中wm_concat()函数的使用

    Oracle中wm_concat()函数的使用 wm_concat()函数是oracle行列转换函数,该函数可以把列值以‘,’分割开来,并显示成一行. 1.原数据: 2.把结果分组以‘|’分隔,以一行 ...

  6. SQLServer2005 提示 '其他会话正在使用事务的上下文'

    MSDN上看了一下说是sql server 2005不支持在分布式事务处理中存在指向本地的链接服务器(环回链接服务器) 这个是官方的回答 个人认为,应该是在事务中,使用了链接服务器访问进行跨库访问引起 ...

  7. 用DependanceProperty做Dynamic换Icon

    1:做Icon用Canvas还是DrawingBrush? Canvas的例子:

  8. OC:属性、点语法、KVC

    //属性的属性 属性定义在一个 .h文件里,在这个.h文件里可以定义实例变量(就是这个类的特征),也可以通过   @protery(属性约束关键字) 属性名字类型 属性名 来定义一些属性,在prope ...

  9. OC: 类的扩展、类的延展、协议、 NSDate

      NSDateFormatter 指定⽇日期格式: NSDateFormatter * formatter = [[NSDateFormatter alloc] init]; [formatter ...

  10. C# 获取字符串中的数字

    /// <summary> /// 获取字符串中的数字(不包含小数点) /// </summary> /// <param name="str"> ...