Author | Message | Time |
---|---|---|
Vision | Im in c++ class right now and we need to write a program that you input a number and it outputs the number in Roman numerals can someone give me an idea for wat to use because i havent been to school to find out how were suppost to and the teachers gay and wont tell me... | March 3, 2004, 8:03 PM |
Eibro | Something that immediatly comes to mind: [code]std::string returnString; const long rnChars[] = { 'M', 'D', 'C', 'L', 'X', 'V', 'I' }; const long rnDigits[] = { 1000, 500, 100, 50, 10, 5, 1, 0 }; for ( long i = 0; i < rnDigits[i] != 0; ++i ) { long quotient = input / rnDigits[i]; long remainder = input % rnDigits[i]; returnString.append( quotient, rnChars[i] ); input = remainder; }[/code]The above will *not* work. It should at least get you started. Basically, you'll want to keep extracting digits and dividing to figure out how many multiples of each letter to add. | March 3, 2004, 9:22 PM |
Vision | thnx :) anymore suggestions? | March 5, 2004, 3:21 AM |
Mephisto | You should just do this by yourself. :P I've written one of these along time ago. I'll post the source if you find you desperately need it. :P But it's rather simple, just a matter of logic more or less. | March 5, 2004, 3:59 AM |