|
int main() { int num, i= 0, ii; int currentDivide[7] = {1000, 500, 100, 50, 10, 5, 1}; int count[7]; char characters[7] = "'M', 'D', 'C', 'L', 'X', 'V', 'I'"; while((scanf("%c", characters)) != '\n'){ for(i = 0; i < 7; i++){ count[i] = num / currentDivide[i]; num %= currentDivide[i]; } for(i = 0; i < 7; i++) if(count[i] != 4 || i == 0) for(ii = 0; ii < count[i]; ii++) cout<<currentDivide[i]; else cout<<currentDivide[i]<< currentDivide[i-1]; }
return 0; }
Please, I want this codes to print the Numeric equivalent of the Roman Figures. I have a bit changed it to the switch/ case but special cases like VI/IV, XI/IX, LC/CL will not come up separetely. The are 6, 11, and 150 respectively. See the basic case condition
switch(cha){
case 'M': sum += 1000; cout<<sum; ::: ::: ::: case 'I': sum += 1; cout<<sum; }
This thus gives VI/IV as 6 instead of 6/4. Same as IX/XI giving 11 instead of 9/11. Can you help for the special cases like IV/VI, XI/IX, LX/XL MX/XM etc? My email address is smart_ikhu@hotmail.comī Thanks.
|