主题:[原创]进制转换
输一个M进制数,把它转成十进制,程序如下:
CLS
INPUT A$, M
L = LEN(A$)
I = 0
S$ = ""
DO
X$ = MID$(A$, L, 1)
IF X$ >= "0" AND X$ <= "9" THEN ’数字
A = VAL(X$) * M ^ I
ELSEIF X$ >= "A" AND X$ <= "Z" THEN ‘如是十六进制字符话
A = (ASC(X$) - 55) * M ^ I
ELSE
PRINT "DATA NO!": END ’数据有误
END IF
S = S + A
L = L - 1
I = I + 1
LOOP UNTIL L = 0
PRINT S
END
还行吧!
CLS
INPUT A$, M
L = LEN(A$)
I = 0
S$ = ""
DO
X$ = MID$(A$, L, 1)
IF X$ >= "0" AND X$ <= "9" THEN ’数字
A = VAL(X$) * M ^ I
ELSEIF X$ >= "A" AND X$ <= "Z" THEN ‘如是十六进制字符话
A = (ASC(X$) - 55) * M ^ I
ELSE
PRINT "DATA NO!": END ’数据有误
END IF
S = S + A
L = L - 1
I = I + 1
LOOP UNTIL L = 0
PRINT S
END
还行吧!