http://poj.org/problem?id=2121
Inglish-Number Translator
Time Limit: 1000MS | Memory Limit: 65536K | |
Total Submissions: 3671 | Accepted: 1460 |
Description
In this problem, you will be given one or more integers in English. Your task is to translate these numbers into their integer representation. The numbers can range from negative 999,999,999 to positive 999,999,999. The following is an exhaustive list of English words that your program must account for:
negative, 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, hundred, thousand, million
negative, 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, hundred, thousand, million
Input
The input consists of several instances. Notes on input:
The input is terminated by an empty line.
- Negative numbers will be preceded by the word negative.
- The word "hundred" is not used when "thousand" could be. For example, 1500 is written "one thousand five hundred", not "fifteen hundred".
The input is terminated by an empty line.
Output
The answers are expected to be on separate lines with a newline after each.
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
题意:把英文的数字翻译成阿拉伯数字。
想用数组把对应的英文字母保存起来但是不熟练,看到一大牛直接爆,那我也就直接爆就是了
关键的地方是处理
hundred, thousand, million 。自己用笔模拟下就有感觉了。。
#include<iostream>
#include<cstdio>
#include<cstring>
#define maxn 100
char s[maxn];
int sum=0,ans=0;
int main()
{
}