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.
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.
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<bits/stdc++.h>///Hastiness using namespace std; map<int,string> M; map<int,string> M1; map<int,string> M2; void init() { 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[0] = "zero"; M1[1] = "ten"; M1[2] = "twenty"; M1[3] = "thirty"; M1[4] = "forty"; M1[5] = "fifty"; M1[6] = "sixty"; M1[7] = "seventy"; M1[8] = "eighty"; M1[9] = "ninety"; M2[0] = "ten"; M2[1] = "eleven"; M2[2] = "twelve"; M2[3] = "thirteen"; M2[4] = "fourteen"; M2[5] = "fifteen"; M2[6] = "sixteen"; M2[7] = "seventeen"; M2[8] = "eighteen"; M2[9] = "nineteen"; } int main() { int t,n,a,b,c,c1,c2,d; init(); while(~scanf("%d",&n)) { a=n/1000; b=n%1000/100; c1=n%100; c=c1/10; d=n%10; if(a!=0) { if(b==0&&c==0&&d==0) { cout<<M[a]<<" thousand\n"; continue; } else { cout<<M[a]<<" thousand and "; } } if(b!=0) { if(c==0&&d==0) { cout<<M[b]; printf(" hundred\n"); continue; } else { cout<<M[b]; printf(" hundred and "); } } if(c1>=20) { if(d==0) { cout<<M1[c]<<endl; continue; } else { cout<<M1[c]<<'-'<<M[d]<<endl; continue; } } if(c1<20&&c1>=10) { cout<<M2[d]<<endl; continue; } if(c1<10) { cout<<M[d]<<endl; } } }