Foxtable(狐表)用户栏目专家坐堂 → 如何可以把數字變成羅馬數字?


  共有3505人关注过本帖树形打印复制链接

主题:如何可以把數字變成羅馬數字?

帅哥哟,离线,有人找我吗?
大红袍
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2015/9/28 9:42:00 [显示全部帖子]

dim n as integer = 123

Dim arabic() As Integer =  New Integer(13) {}
Dim roman() As String =  New String(13) {}
Dim i As Integer =  0
Dim o As String =  ""

arabic(0) = 1000
arabic(1) = 900
arabic(2) = 500
arabic(3) = 400
arabic(4) = 100
arabic(5) = 90
arabic(6) = 50
arabic(7) = 40
arabic(8) = 10
arabic(9) = 9
arabic(10) = 5
arabic(11) = 4
arabic(12) = 1

roman(0) = "M"
roman(1) = "CM"
roman(2) = "D"
roman(3) = "CD"
roman(4) = "C"
roman(5) = "XC"
roman(6) = "L"
roman(7) = "XL"
roman(8) = "X"
roman(9) = "IX"
roman(10) = "V"
roman(11) = "IV"
roman(12) = "I"

While n > 0
    While n >= arabic(i)
        n = n - arabic(i)
        o = o + roman(i)
    End While
    i = i + 1
End While

msgbox(o)


 回到顶部