A interview question (conversion to the digital currency into uppercase said, if 123.45 is converted into 100 壹 百 元

xiaoxiao2021-03-06  14

[ASP code]

Response.write (CBMoney (12345.67))

Function CBMoney (NUM) IF INSTR (Num, ")> 0 Then Arrnum = Split (Num,". "Znum = arrnum (0) xnum = arrnum (1) Hasdot = true else znum = Num End ifss bmoney = "Zero,,, 叁,,,, 柒, 捌, 玖, 玖, 拾, a, a,", ",",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, 元, Znum) zmunit = Right (Replace (Zmunit, ",", ""), ZLENNUM) DIM Newzunit for i = 1 to len (zmunit) newzunit = newzunit & mid (zmunit, i, 1) & "," next zmunit = left Newzunit, neWZUNIT) -1) Arrzmunit = split (zmunit, ",") xmunit = "angle, division" arrxmunit = split (xmunit, ",") DIM strbmoney for i = 1 to zlennum nchar = cint (MID Znum, I, 1)) Strbmoney = StrBmoney & Arrbmoney (nchar) & "" & arrzmunit (i-1) & "" Next if Hasdot Then Xlennum = LEN (XNUM) for i = 1 to Xlennum nchar = CINT (MID (XNUM, I, 1)) StrBmoney = Strbmoney & Arrbmoney (Nchar) & "" & Arrxmunit (i-1) & "" Next End End IF CBMONEY = StrbmoneyEnd Function

[ASP.NET (C #)]

Description: Cmoney.aspx page omitted, there is three web control controls, TextBoxt (ID = txtnum), Button, Label (ID = lblret)

File name: cmoney.aspx.cs (cbmoney is the main function)

转载请注明原文地址:https://www.9cbs.com/read-48679.html

New Post(0)