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. jdk5下载链接

    查看jdk版本 java -version JDK下载 最新版本 http://www.oracle.com/technetwork/java/javase/downloads/index.html ...

  2. B - Kefa and Company

    B - Kefa and Company Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I6 ...

  3. sql数据库delete删除后怎么恢复,这是网上找的答案。。希望大神验证指教一下

    使用Log Explorer查看和恢复数据 Log Explorer 4.1.可用于SQL Server2005的日志查看工具 下载地址: http://download.csdn.net/sourc ...

  4. Codeforces 467C. George and Job (dp)

    题目链接:http://codeforces.com/contest/467/problem/C 求k个不重叠长m的连续子序列的最大和. dp[i][j]表示第i个数的位置个序列的最大和. 前缀和一下 ...

  5. hdoj 5327 Olmpiad

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5327 #include<stdio.h> #include<cstring> ...

  6. [置顶] Linux信号相关笔记

    最近又温习了一遍Linux中的信号知识,发现有很多东西以前没有注意到,就通过这篇博客记录一下,巩固一下知识点. 一,信号基础: 信号是什么?为了回答这个问题,首先要从异常说起,这里的异常不是指c++/ ...

  7. 移动端类似IOS的滚动年月控件(需要jQuery和iScroll)

    一. 效果图 二. 功能介绍 支持滚动和点击选择年月.(目前只支持设置年月的最大最小值,不支持整体的最大最小值) 三. 代码 1. 在你的html中添加如下代码: 直接加载<body>里面 ...

  8. 学习JQuery中文文档之map()函数和get()函数

    今天学到一个新的函数map(). map(callback) 官方概述: 将一组元素转换成其他数组(不论是否是元素数组) 你可以用这个函数来建立一个列表,不论是值.属性还是CSS样式,或者其他特别形式 ...

  9. thinkphp 3+ 观后详解 (1)

    最近面试了一些公司,发现自己的对于架构能力的不足,于是决定开始从最基本的代码做起.先看看大牛们怎么架构整个框架的.鉴于国外的框架比较难懂,于是就选择了国内比较流行的thinkphp来进行研究. 下面写 ...

  10. putty 中文乱码解决方法

    解决putty.exe 中文乱码的问题 export NLS_LANG="AMERICAN_AMERICA.ZHS16GBK"