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
C++
#include<iostream>
#include<map>
#include<string>
#include<cstring>
using namespace std;
int main()
{
    int a,b,c,d;
    int n[5];
    map<int,string>m;
    map<int,string>s;
    m[0]="zero";
    m[1]="one";
    m[2]="two";
    m[3]="three";
    m[4]="four";
    m[5]="five";
    m[6]="six";
    m[7]="seven";
    m[8]="eight";
    m[9]="nine";
    m[10]="ten";
    m[11]="eleven";
    m[12]="twelve";
    m[13]="thirteen";
    m[14]="fourteen";
    m[15]="fifteen";
    m[16]="sixteen";
    m[17]="seventeen";
    m[18]="eighteen";
    m[19]="nineteen";
    s[2]="twenty";
    s[3]="thirty";
    s[4]="forty";
    s[5]="fifty";
    s[6]="sixty";
    s[7]="seventy";
    s[8]="eighty";
    s[9]="ninety";
    while(cin>>b)
    {
        a=0;
        c=b;
        if(b<20)
            cout<<m[b]<<endl;
        else
        {
            if(b>=1000)
            {
                cout<<m[b/1000]<<" thousand";
                b=b%1000;a=1;
            }
            if(b>=100)
            {
                if(a==1)
                {
                    cout<<" and ";
                    a=0;
                }
                cout<<m[b/100]<<" hundred";
                b=b%100;a=1;
            }
            if(b>=20)
            {
                if(a==1)
                {
                    cout<<" and ";
                    a=0;
                }
                cout<<s[b/10];
                if(b%10!=0)
                    cout<<"-"<<m[b%10];
            }
            else if(b!=0)
            {
                if(a==1)
                {
                    cout<<" and ";
                    a=0;
                }
                cout<<m[b];
            }
            cout<<endl;
        }
    }
    return 0;
}
 
京公网安备 11010502036488号