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 <stdio.h>
#include <string.h> int main(){
int number;
int a;
int b;
int c;
char digit[][];
char ten[][];
int flag=; strcpy(digit[],"zero");
strcpy(digit[],"one");
strcpy(digit[],"two");
strcpy(digit[],"three");
strcpy(digit[],"four");
strcpy(digit[],"five");
strcpy(digit[],"six");
strcpy(digit[],"seven");
strcpy(digit[],"eight");
strcpy(digit[],"nine");
strcpy(digit[],"ten");
strcpy(digit[],"eleven");
strcpy(digit[],"twelve");
strcpy(digit[],"thirteen");
strcpy(digit[],"fourteen");
strcpy(digit[],"fifteen");
strcpy(digit[],"sixteen");
strcpy(digit[],"seventeen");
strcpy(digit[],"eighteen");
strcpy(digit[],"nineteen");
strcpy(digit[],"twenty"); strcpy(ten[],"twenty");
strcpy(ten[],"thirty");
strcpy(ten[],"forty");
strcpy(ten[],"fifty");
strcpy(ten[],"sixty");
strcpy(ten[],"seventy");
strcpy(ten[],"eighty");
strcpy(ten[],"ninety"); while(scanf("%d",&number)!=EOF){
a=number/;
b=number/%;
c=number%; if(a!=){ //当千位不为0时才打印
flag=;
printf("%s thousand",digit[a]); if(b!= || c!=) //后面不为0才打印"and"
printf(" and ");
} if(b!=){
flag=;
printf("%s hundred",digit[b]); if(c!=)
printf(" and ");
} if(c<=){
if(flag== && c==) //前面已经打印,此时的0不打印
; else if(flag== && c==) //前面没有打印,此时的0打印
printf("zero"); else
printf("%s",digit[c]); //不为0直接打印
} else{
printf("%s",ten[c/]); //打印十位数 if(c%!=) //如果还有个位数,打印"-"和个位数
printf("-%s",digit[c%]);
} printf("\n"); } return ;
}