hdoj-1727 Hastiness

79 篇文章 0 订阅

Hastiness

Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1801    Accepted Submission(s): 699


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<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
int main()
{
    char a[21][10],b[10][10];
    strcpy(a[0],"zero");
    strcpy(a[1],"one");
    strcpy(a[2],"two");
    strcpy(a[3],"three");
    strcpy(a[4],"four");
    strcpy(a[5],"five");
    strcpy(a[6],"six");
    strcpy(a[7],"seven");
    strcpy(a[8],"eight");
    strcpy(a[9],"nine");
    strcpy(a[10],"ten");
    strcpy(a[11],"eleven");
    strcpy(a[12],"twelve");
    strcpy(a[13],"thirteen");
    strcpy(a[14],"fourteen");
    strcpy(a[15],"fifteen");
    strcpy(a[16],"sixteen");
    strcpy(a[17],"seventeen");
    strcpy(a[18],"eighteen");
    strcpy(a[19],"nineteen");
    strcpy(a[20],"twenty");
    strcpy(b[0],"twenty");
    strcpy(b[1],"thirty");
    strcpy(b[2],"forty");
    strcpy(b[3],"fifty");
    strcpy(b[4],"sixty");
    strcpy(b[5],"seventy");
    strcpy(b[6],"eighty");
    strcpy(b[7],"ninety");
    int n,m;
    while(~scanf("%d",&n))
    {
        if(!n){
            printf("zero\n");
            continue;
        }
        if(n>=1000)
        {
            m=n/1000;
            printf("%s thousand",a[m]);
            n-=m*1000;
            if(!n)
            {
                printf("\n");
                continue;
            }
            printf(" and ");
        }
        if(n>=100)
        {
            m=n/100;
            printf("%s hundred",a[m]);
            n-=m*100;
            if(!n){
                printf("\n");
                continue;
            }
            printf(" and ");
        }
        if(n)
        {
            if(n<=20)
                printf("%s\n",a[n]);
            else
            {
                m=n/10;
                printf("%s",b[m-2]);
                n-=m*10;
                if(!n)
                {
                    printf("\n");
                    continue;
                }
                printf ("-%s\n", a[n]);
            }
        }
    }
    return 0;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值