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...
Something that immediatly comes to mind:
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;
}
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.
thnx :) anymore suggestions?
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.