Hastiness(1727)
Hastiness
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1441 Accepted Submission(s): 571
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
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1441 Accepted Submission(s): 571
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-fourzero
#include
#include #include #include #include int main() { int t; int a,b,c,d,flag,i,l; char name[10]; char s[11][10]={"zero","one","two","three","four","five","six","seven","eight","nine"}; char shi[11][10]={"ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"}; char ty[10][10]={"ten","twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"}; while(scanf("%d",&t)!=EOF) { flag=0; sprintf(name,"%d",t); l=strlen(name); if(l==1) { printf("%s
",s[name[0]-'0']); continue; } if(l==4) { a=name[0]-'0'; b=name[1]-'0'; c=name[2]-'0'; d=name[3]-'0'; } else if(l==3) { a=0; b=name[0]-'0'; c=name[1]-'0'; d=name[2]-'0'; } else if(l==2) { a=0,b=0; c=name[0]-'0'; d=name[1]-'0'; } //printf("%d %d %d %d",a,b,c,d); if(a>0) { printf("%s thousand",s[a]); flag++; } if(b>0) { if(flag==0) { printf("%s hundred",s[b]); flag++; } else printf(" and %s hundred",s[b]); } if(c>0) { if(c==1) { if(flag==0) { printf("%s",shi[d]); flag++; } else printf(" and %s",shi[d]); } else { if(flag==0) { if(d==0) {printf("%s",ty[c-1]); flag++;} else {printf("%s-%s",ty[c-1],s[d]); flag++;} } else { if(d==0) printf(" and %s",ty[c-1]); else printf(" and %s-%s",ty[c-1],s[d]); } } } if(c==0 && (a!=0 || b!=0) && d!=0) printf(" and %s",s[d]); printf("
"); } return 0; }