#include #include using namespace std; string convert (int input) { string rv = ""; while (input >= 1000) { rv += "M"; input -= 1000; } if (input >= 900) { rv += "CM"; input -= 900; } if (input >= 500) { rv += "D"; input -= 500; } if (input >= 400) { rv += "CD"; input -= 400; } while (input >= 100) { rv += "C"; input -= 100; } if (input >= 90) { rv += "XC"; input -= 90; } if (input >= 50) { rv += "L"; input -= 50; } if (input >= 40) { rv += "XL"; input -= 40; } while (input >= 10) { rv += "X"; input -= 10; } if (input >= 9) { rv += "IX"; input -= 9; } if (input >= 5) { rv += "V"; input -= 5; } if (input >= 4) { rv += "IV"; input -= 4; } while (input) { rv += "I"; input--; } return rv; } void main (void) { int input = 1; while (input) { cout << "Please enter the number to convert (0 to quit): "; cin >> input; if (input) cout << "The converted number is: " << convert(input) << endl; } }