/**
* @param {number} num
* @return {string}
*/
var intToRoman = function(num) {
let Rnum = ''
function changeRnum(number,one='',five='',ten=''){
switch(number){
case 9:
Rnum+=(one+ten)
break
case 8:
Rnum+=(five+one+one+one)
break
case 7:
Rnum+=(five+one+one)
break
case 6:
Rnum+=(five+one)
break
case 5:
Rnum+=five
break
case 4:
Rnum+=(one+five)
break
case 3:
Rnum+=(one+one+one)
break
case 2:
Rnum+=(one+one)
break
case 1:
Rnum+=one
break
case 0:
break
}
}
let thousand = parseInt(num/1000)
changeRnum(thousand,'M')
let hundred = parseInt(num/100)
changeRnum(hundred%10,'C','D','M')
let ten = parseInt(num/10)
changeRnum(ten%10,'X','L','C')
let one = num%10
changeRnum(one,'I','V','X')
return Rnum
};
算法
https://leetcode-cn.com/problems/integer-to-roman/submissions/
通过判断和传参,来进行修改
阅读
https://www.freecodecamp.org/news/the-last-ten-years-or-how-to-get-better-at-anything/
技巧(中间层)
中间层可以帮助我们在数据产生变化的时候进行判断来决定是否要进行操作。 需要加中间层:数据改变,主题,http,消息,网关
分享(webpack优化)
https://www.toutiao.com/a6775483622695633419/?tt_from=weixin&utm_campaign=client_share&wxshare_count=1×tamp=1577580767&app=news_article&utm_source=weixin&utm_medium=toutiao_android&req_id=2019122908524601002607720537D01ADC&group_id=6775483622695633419