hdoj-1727Hastiness

来源:互联网 发布:竞彩预测软件 编辑:程序博客网 时间:2024/05/18 21:51

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
20341234123240
 

Sample Output
two thousand and thirty-fourone thousand and two hundred and thirty-fourone hundred and twenty-threetwenty-fourzero
 
题目链接
 
#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;}