多位數乘法計算

2021-06-05 08:48:33 字數 1306 閱讀 8380

option base 1

private sub command1_click()

dim m as string

dim n as string

m = trim(text1.text)

n = trim(text2.text)

dim number1() as byte

dim number2() as byte

redim number1(len(m))

redim number2(len(n))

dim index as byte

for index = 1 to len(m) step 1

number1(index) = mid(m, index, 1)

next index

for index = 1 to len(n) step 1

number2(index) = mid(n, index, 1)

next index

dim result() as byte

redim result(len(m) + len(n))

dim mcarry as byte

dim acarry as byte

dim remainder as integer

dim i as integer, j as integer

dim mtemp as integer, atemp as integer

for i = len(n) to 1 step -1

for j = len(m) to 1 step -1

mtemp = number1(j) * number2(i) + mcarry

mcarry = mtemp \ 10

remainder = mtemp mod 10

atemp = remainder + result(i + j) + acarry

acarry = atemp \ 10

result(i + j) = atemp mod 10

next j

result(i) = mcarry + acarry

mcarry = 0

acarry = 0

next i

dim mstras string

for index = 1 to len(n) + len(m)

mstr = mstr & str(result(index))

next j

label3.caption = mstr

end sub

彙編 多位數相加

上一次彙編寫到,只是個位數的簡單相加,只需要判斷兩者相加有無進製,進製即進一,在輸出視窗輸出一先。遇到多位數後,會變複雜很多,事實上彙編裡面可以實現相加,難題在於需要把和轉成ascii碼顯示在dos視窗。所以需要把和乙個乙個數提取,轉成ascii。程式如下 datas segment op1 dw ...

004 美化多位數字

將給定的數字以逗號分隔的形式顯示出來 bin bash filename nicenum.sh 可接受兩個選項 dd decimal pointa,小數分隔符 和td thousands delimiter,千位分隔符 nicenumber decimal fi thousands int whil...

逆波蘭演算法(多位數運算)

問題描述 在計算機中,算術表示式由常量 變數 運算子和括號組成。由於不同的運算子具有不同的優先順序,又要考慮括號,因此,算術表示式的求值不可能嚴格地從左到右進行。因而在程式設計時,借助棧實現。任務要求 演算法輸入 乙個算術表示式,由常量 變數 運算子和括號組成 以字串形式輸入 為簡化,規定運算元只能...