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. Supports BorlandIDEServices

    Delphi: procedure SetKeystrokeDebugging(Debugging: Boolean); var Dialog: IOTAKeyboardDiagnostics beg ...

  2. HDU 4619 Warm up 2(2013多校2 1009 二分匹配)

    Warm up 2 Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)Total S ...

  3. Hibernate资源

    正在学马士兵Hibernate的同学来看这里,这里提供了他视频里需要的JAR包,请尽情下载,给好评喔. 一.Hibernate 3.3.2 核心JAR包 http://pan.baidu.com/s/ ...

  4. ado通用操作数据单元

    DELPHI开发2层C/S数据库应用程序,许多人通过ADOQUERY或ADOTABLE直接操作数据库,其实这种方法虽然最为直接,但有其缺点:如果以后要将程序升级为3层C/S会非常困难.而通过像下面的通 ...

  5. Codeforces 707 E. Garlands (二维树状数组)

    题目链接:http://codeforces.com/problemset/problem/707/E 给你nxm的网格,有k条链,每条链上有len个节点,每个节点有一个值. 有q个操作,操作ask问 ...

  6. POJ1201Intervals(差分约束系统)

    昨天看了下差分约数系统的含义,其实就是如果有n个变量在m个形如aj-ai>=bk条件下,求解的此不等式的方法. 而这种不等式的解法其实就是转化为图论的最小路的算法求解的.我们将上面的不等式边形后 ...

  7. apache与IIS端口冲突修改和需要使用 SSL 查看该资源”错误

    改变Apache端口等配置修改方法 www.educity.cn 发布者:jsb200421 来源:网络转载 发布日期:2014年01月02日 如何改变Apache端口:找到Apache安装目录下co ...

  8. hdoj 5344 MZL's xor

    题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=5344 #include<stdio.h> #include<cstring> ...

  9. Oracle 数据库链接

    SQL> CREATE DATABASE LINK   mydblink 2    CONNECT TO   test   IDENTIFIED BY   test123 3    USING  ...

  10. JAVA核心技术--继承

    1.继承:向上追溯,对同一批类的抽象,延续和扩展父类的一切信息! 1)关键字:extends      例如,父类是Animal,子类是Dog;   eg: public class Dog exte ...