题目
原题链接
Given an integer, convert it to a roman numeral.
Input is guaranteed to be within the range from 1 to 3999.
思路
TODO:之后添加
代码
class Solution {
func intToRoman(num: Int) -> String {
var str:String = ""
var num_local:Int = num
var symbol:[String] = ["M","CM","D","CD","C","XC","L","XL","X","IX","V","IV","I"]
var value:[Int] = [1000,900,500,400,100,90,50,40,10,9,5,4,1]
for(var i :Int = 0;num_local != 0;i++){
while(num_local >= value[i])
{
num_local -= value[i]
str += symbol[i]
}
}
return str
}
}