Verdis Quo

来源:百度知道 编辑:UC知道 时间:2024/06/29 22:14:18
Verdis Quo
Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 127 Accepted Submission(s): 108

Problem Description
The Romans used letters from their Latin alphabet to represent each of the seven numerals in their number system. The list below shows which
letters they used and what numeric value each of those letters represents:

I = 1
V = 5
X = 10
L = 50
C = 100
D = 500
M = 1000

Using these seven numerals, any desired number can be formed by following the two basic additive and subtractive rules. To form a number using
the additive rule the Roman numerals are simply written from left to right in descending order, and the value of each roman numeral is added
together. For example, the number MMCLVII has the value 1000 + 1000 + 100 + 50 + 5 + 1 + 1 = 2157. Using the addition rule alone could lead to
very long strings of letters, so the

//请务必恪守输入准则,
//罗马字母务必大写。
//本程序运行成功。

#include<iostream>
#include<string>
#include<vector>
#include<numeric>
using namespace std;

int convertor(string strobj)
{
enum Alphabet
{
I = 1 ,
V = 5 ,
X = 10 ,
L = 50 ,
C = 100 ,
D = 500 ,
M = 1000
};

vector<int> process;
for( string::iterator iter = strobj.begin(); iter != strobj.end(); iter++ )
{
switch(*iter)
{
case 'I': process.push_back(I); break;
case 'V': process.push_back(V); break;
case 'X': process.push_back(X); break;
case 'L': process.push_back(L); break;
case 'C': process.push_back(C); break;
case 'D': process.push_back(D); break;
case 'M': process.push_back(M); break;
}
};

for( vector<int>::iterator