js阿拉伯数字转换罗马数字

function toRoman(num){
			if(isNaN(num)) return num;
			
			var a=[["","I","II","III","IV","V","VI","VII","VIII","IX"],
                          ["","X","XX","XXX","XL","L","LX","LXX","LXXX","XCC"],
                          ["","C","CC","CCC","CD","D","DC","DCC","DCCC","CM"]];
			var roman = "";
			var t=0;
			for(var m=0, i=1000; m<3; m++,i/=10){
             	t=Math.floor((num%i)/(i/10));
            	roman += a[2-m][t];
            }
			return roman;
		}
 

你可能感兴趣的:(C++,c,C#)