deno.land / x / masx200_leetcode_test@10.6.5 / integer-to-roman / index.ts

نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
export default function intToRoman(num: number): string { return [ M[Math.floor((num / 1000) % 10)], C[Math.floor((num / 100) % 10)], X[Math.floor((num / 10) % 10)], I[Math.floor(num % 10)], ].join("");}const M = ["", "M", "MM", "MMM"]; //# 1000,2000,3000const C = ["", "C", "CC", "CCC", "CD", "D", "DC", "DCC", "DCCC", "CM"]; //# 100~900const X = ["", "X", "XX", "XXX", "XL", "L", "LX", "LXX", "LXXX", "XC"]; //# 10~90const I = ["", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX"]; //# 1~9
masx200_leetcode_test

Version Info

Tagged at
a year ago