Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- string convertToRoman(int num) {
- int decNum = [ 1, 4, 5, 9, 10, 40, 50, 90, 100, 400, 500, 900, 1000 ];
- string romNum = [ 'I', 'IV', 'V', 'IX', 'X', 'XL', 'L', 'XC', 'C', 'CD', 'D', 'CM', 'M' ];
- string romanNum = "";
- while (num > 0){
- int i = 0;
- while(num >= decNum[i+1]){
- i++;
- }
- romanNum += romNum[i];
- num -= decNum[i];
- }
- return romanNum;
- }
Advertisement
Add Comment
Please, Sign In to add comment