Roman_Numerals

Convert Roman numerals to Arabic form

How do i find a element in a array?
print out the index?

So far....

const char*unit[9] = {"I","II","III","IV","V","VI","VII","VIII","IX"};
const char* tens[9] = {"X", "XX", "XXX", "XL", "L", "LX", "LXX", "LXXX", "XC"};
const char* hundreds[9] = {"C", "CC", "CCC", "CD", "D", "DC", "DCC", "DCCC", "CM"};
const char* thousands[3] = {"M", "MM", "MMM"};

string str;

cout << "Enter the Roman Numeral in Capital letters (e.g. CCXIX) : ";
cin>> str;
closed account (o3hC5Di1)
Hi there,

you would do, for example:

 
std::cout << unit[2];  //outputs III 


For more information: http://www.cplusplus.com/doc/tutorial/arrays/

All the best,
NwN
The Input is The Roman_Numeral(eg...IX) the output should be 9. I also need to do loop so when the IX is not found in the array(units) it should move on to the next array(tens) and so on..
Topic archived. No new replies allowed.