Code:
#include <iostream>
using namespace std;
const int roemi[] = {5000, 4000, 1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1};
const char roemc[][3]={"A", "MA", "M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I"};
const int arraynum = 15;
const int maxnum = 8888;
int main(int argc, char *argv[])
{
int tmp;
cout << "arabisch => roemisch" << endl;
cout << "unter Anwendung der \"Subtraktionsregel\" (1..." << maxnum << ")" << endl;
for(;;) {
cout << "Zahl: " << flush;
cin >> tmp;
if(!tmp)
break;
if(tmp < 1 || tmp > maxnum)
cout << "Ungueltige Zahl" << endl;
else {
cout << "roemisch: ";
for(int i = 0 ; i < arraynum ; i++) {
while(tmp >= roemi[i]) {
tmp -= roemi[i];
cout << roemc[i];
}
}
cout << endl;
}
}
return(0);
}