I suspect the difference between “old” and “new” Roman numerals is in the old and new
programs to implement Roman numerals. Perhaps OP was demonstrated an “old” algorithm that could not handle subtractive Roman numerals.
The numeral LCLIXX is mal-formed, but not invalid.
It is L C L IX X = 50 + 100 + 50 + 9 + 10 = 219.
The correct way to write that today is CCXIX, but CCIXX is also acceptable.
Today only I, X, and C are used subtractively (subtract tenths, not halves), but you can certainly write an algorithm that takes VL as 45, and that would be reasonable. (We would normally write 45 as XLV today.) The problem is that it would make LCLIXX equal to LC L IX X, or 50 + 50 + 9 + 10 = 119.
You should ask your professor about this discrepancy. Should LCLIXX produce 219 or 119? Or worded differently, should V, L, and D be subtractive?
Another note: your program should take input “from the keyboard” (meaning, from standard input == std::cin) and “print out their values” (meaning, to standard output == std::cout).
This is easy enough:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
#include <iostream>
#include <string>
int roman_to_integer( const std::string& s )
{
...
}
int main()
{
std::string s;
while (getline( std::cin, s ))
std::cout << roman_to_integer( s ) << "\n";
}
|
That’s it! The function should do the conversion from the Roman numeral string to int.
Hope this helps.