c++关于罗马数字转阿拉伯数字加强版

主体代码我已经有了,(罗马转阿拉伯),现在要求筛选要只有一个位数是0以外的数其他为0的数,否则重复程序。比如1可以,3可以,11不行,100可以,110不行。

原题:Level 2: Multiple numbers
Extend the program so that it can deal with single digit numbers of any value. A single digit number is one that consists
only of thousands, hundreds, tens, or units. Thus LXX (70) and CD (400) are single digit numbers, but XIV (14) and
MC (1100) are not. Use the same approach as for units digits, but with 4 different arrays, one each for the thousands,
hundreds, tens, and units digits. Try looking for thousands digits first, then for hundreds, and so on. When you find a
match in one of the arrays, print the corresponding value and stop.
Modify the program so that it reads and converts all input numbers until end of file (eof) on standard input. You will
probably be able to do this by simply adding an appropriate reading loop around the code that reads a single line.

我的代码
#include
#include
#include
#include
using namespace std;

int romanToInt(string s) {
int result=0;
map luomab;

luomab.insert(map::value_type('I',1));
luomab.insert(map::value_type('V',5));
luomab.insert(map::value_type('X',10));
luomab.insert(map::value_type('L',50));
luomab.insert(map::value_type('C',100));
luomab.insert(map::value_type('D',500));
luomab.insert(map::value_type('M',1000));
luomab.insert(map::value_type('i',1));
luomab.insert(map::value_type('v',5));
luomab.insert(map::value_type('x',10));
luomab.insert(map::value_type('l',50));
luomab.insert(map::value_type('c',100));
luomab.insert(map::value_type('d',500));
luomab.insert(map::value_type('m',1000));

for(int i=0;i {
if(luomab[s[i]]>=luomab[s[i+1]])
result+=luomab[s[i]];
else
{
result+=(luomab[s[i+1]]-luomab[s[i]]);
i++;
}
}
return result;
}

int main(int argc, char *argv[])
{
string input;

cin>>input;

int result = romanToInt(input);







        cout<<result;

}

https://tieba.baidu.com/p/6907030874