Time Limit: 1000MS | Memory Limit: 65536K | |
Total Submissions: 4840 | Accepted: 1894 |
Description
Input
Output
Sample Input
six negative seven hundred twenty nine one million one hundred one eight hundred fourteen thousand twenty two
Sample Output
6 -729 1000101 814022
Source
CTU Open 2004,UVA 486
AC代码:
#include <iostream> #include <algorithm> #include <cstring> #include <cstdio> using namespace std; int main(){ string t; int sum=0,sum2=0; while(cin>>t){ if(t=="negative")putchar('-'); else if(t=="zero")sum+=0; else if(t=="one")sum+=1; else if(t=="two")sum+=2; else if(t=="three")sum+=3; else if(t=="four")sum+=4; else if(t=="five")sum+=5; else if(t=="six")sum+=6; else if(t=="seven")sum+=7; else if(t=="eight")sum+=8; else if(t=="nine")sum+=9; else if(t=="ten")sum+=10; else if(t=="eleven")sum+=11; else if(t=="twelve")sum+=12; else if(t=="thirteen")sum+=13; else if(t=="fourteen")sum+=14; else if(t=="fifteen")sum+=15; else if(t=="sixteen")sum+=16; else if(t=="seventeen")sum+=17; else if(t=="eighteen")sum+=18; else if(t=="nineteen")sum+=19; else if(t=="twenty")sum+=20; else if(t=="thirty")sum+=30; else if(t=="forty")sum+=40; else if(t=="fifty")sum+=50; else if(t=="sixty")sum+=60; else if(t=="seventy")sum+=70; else if(t=="eighty")sum+=80; else if(t=="ninety")sum+=90; else if(t=="hundred")sum*=100; else if(t=="thousand"){ sum2+=sum*1000; sum=0; } else if(t=="million"){ sum2+=sum*1000000; sum=0; } char c; c=getchar(); if(c=='\n'){ cout<<sum2+sum<<'\12'; sum2=0; sum=0; } } return 0; }
版权声明:本文为博主原创文章,未经博主允许不得转载。
POJ 2121 Inglish-Number Translator
原文地址:http://blog.csdn.net/zp___waj/article/details/47660155