ACM (UVa) : 486


Character words [] [] = { “zero”, “one”, “two”, “three”, “four”, “five”, “six”, “seven”, “eight”, “nine”, “ten”, “eleven”, “twelve”, “thirteen”, “fourteen”, “fifteen”, “sixteen”, “seventeen”, “eighteen”, “nineteen”, “twenty”, “thirty”, “forty”, “fifty”, “sixty”, “seventy”, “eighty”, “ninety” };

int value [] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 30, 40, 50, 60, 70, 80, 90 };

split the whole string into sub string. Like
“negative seven hundred twenty nine”
“negative” “seven” “hundred” “twenty” “nine”

and if these string matches any of array ‘words’ then return the respective values from array ‘value’

Critical input:
six hundred fifty two thousand
five hundred twenty seven million
negative nine hundred ninety nine million nine hundred ninety nine thousand nine hundred ninety nine

Critical output:
652000
527000000
-999999999

Advertisements

One thought on “ACM (UVa) : 486

  1. This is very interesting, You are a very skilled blogger.
    I’ve joined your feed and look forward to seeking more of your magnificent post.
    Also, I’ve shared your website in my social networks!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s