天天看點

HDU 1727 Hastiness(模拟)

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

Sample Output

two thousand and thirty-four

one thousand and two hundred and thirty-four

one hundred and twenty-three

twenty-four

zero

沒啥 想說的 就是坑坑坑, 坑在10幾上了 eleven tw。。。。。想打人

而且代碼寫的賊長

#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int a[];
void day(int i)
{
    if (a[i]==)
    {
        printf("one");
    }
    if (a[i]==)
    {
        printf("two");
    }
    if (a[i]==)
    {
        printf("three");
    }
    if (a[i]==)
    {
        printf("four");
    }
    if (a[i]==)
    {
        printf("five");
    }
    if (a[i]==)
    {
        printf("six");
    }
    if (a[i]==)
    {
        printf("seven");
    }
    if (a[i]==)
    {
        printf("eight");
    }
    if (a[i]==)
    {
        printf("nine");
    }
}
int main()
{
    int m;
    while (~scanf("%d",&m))
    {
        if (m==)
        {
            printf ("zero\n");
            continue;
        }
        memset(a, , sizeof(a));
        int k=,i,j;
        while (m)
        {
            a[k--] = m%;
            m = m/;
        }
        for (i=; i<; i++)
        {
            if (i==)
            {
                day(i);
                if (a[i]!=)
                    printf (" thousand");
                if (a[i]!=&&(a[i+]!=||a[i+]!=||a[i+]!=))
                    printf (" and ");
            }
            if (i==)
            {
                day(i);
                if (a[i]!=)
                    printf (" hundred");
                if (a[i]!=&&(a[i+]!=||a[i+]!=))
                {
                    printf (" and ");
                }
            }
            if (i==)
            {
                if (a[i]!=)
                {
                    if (a[i]==)
                    {
                        printf("ten");
                    }
                    if (a[i]==)
                    {
                        printf("twenty");
                    }
                    if (a[i]==)
                    {
                        printf("thirty");
                    }
                    if (a[i]==)
                    {
                        printf("forty");
                    }
                    if (a[i]==)
                    {
                        printf("fifty");
                    }
                    if (a[i]==)
                    {
                        printf("sixty");
                    }
                    if (a[i]==)
                    {
                        printf("seventy");
                    }
                    if (a[i]==)
                    {
                        printf("eighty");
                    }
                    if (a[i]==)
                    {
                        printf("ninety");
                    }
                    if (a[i]!=&&a[i+]!=)
                        printf ("-");
                }
            }
            if (i==)
            {
                if (a[i-]!=)
                {
                    if (a[i]==)
                    {
                        printf("one");
                    }
                    if (a[i]==)
                    {
                        printf("two");
                    }
                    if (a[i]==)
                    {
                        printf("three");
                    }
                    if (a[i]==)
                    {
                        printf("four");
                    }
                    if (a[i]==)
                    {
                        printf("five");
                    }
                    if (a[i]==)
                    {
                        printf("six");
                    }
                    if (a[i]==)
                    {
                        printf("seven");
                    }
                    if (a[i]==)
                    {
                        printf("eight");
                    }
                    if (a[i]==)
                    {
                        printf("nine");
                    }
                }
                else if (a[i-]==)
                {
                    if (a[i]==)
                        printf ("ten");
                    if (a[i]==)
                    {
                        printf("eleven");
                    }
                    if (a[i]==)
                    {
                        printf("twelve");
                    }
                    if (a[i]==)
                    {
                        printf("thirteen");
                    }
                    if (a[i]==)
                    {
                        printf("fourteen");
                    }
                    if (a[i]==)
                    {
                        printf("fifteen");
                    }
                    if (a[i]==)
                    {
                        printf("sixteen");
                    }
                    if (a[i]==)
                    {
                        printf("seventeen");
                    }
                    if (a[i]==)
                    {
                        printf("eighteen");
                    }
                    if (a[i]==)
                    {
                        printf("nineteen");
                    }
                }
            }

        }
        printf ("\n");
    }
}