'大數除法
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim a = "1234567890123456788999999"
Dim b = "12345678901234567890"
Dim q = 0
While a.Length > b.Length Or a.Length = b.Length And a >= b
q = q + 1
a = bigSub(a, b)
End While
MsgBox(q)
End
End Sub
Function bigSub(ByVal n1, ByVal n2)
Dim a(100)
Dim b(100)
Dim d(100)
Dim i1 = 0
For i = n1.Length - 1 To 0 Step -1
a(i1) = Val(n1.Chars(i))
i1 = i1 + 1
Next
Dim i2 = 0
For i = n2.Length - 1 To 0 Step -1
b(i2) = Val(n2.Chars(i))
i2 = i2 + 1
Next
Dim imax = IIf(i1 > i2, i1, i2)
Dim c = 0
For i = 0 To imax
If a(i) - c >= b(i) Then
d(i) = a(i) - b(i) - c
c = 0
Else
d(i) = a(i) - b(i) - c + 10
c = 1
End If
Next
Dim str = ""
For i = 0 To imax
str = d(i) & str
Next
While Microsoft.VisualBasic.Left(str, 1) = "0"
str = Microsoft.VisualBasic.Right(str, str.Length - 1)
End While
Return (str)
End Function
End Class
標籤雲
visual basic 2008
(157)
訊息分享
(111)
Visual Studio 2008
(64)
wpf
(37)
每日一句
(35)
cpp
(30)
python
(26)
Silverlight
(22)
C++
(18)
Network Security
(15)
全國技藝競竇
(14)
好文分享
(11)
.Net
(10)
Blogger
(10)
名詞解釋
(10)
研討會
(10)
Excel
(9)
書籍介紹
(9)
每日一小品
(9)
電腦黑白講
(8)
Visual Studio 201X
(7)
分享
(7)
網頁設計
(7)
CSS
(5)
Algorithm
(4)
Network
(3)
PHP
(3)
Access
(2)
SA
(2)
VB.Net
(2)
VBA
(2)
WireShark
(2)
Word
(2)
php html
(2)
其他好東東
(2)
分類整理
(2)
Asp.Net
(1)
Batch
(1)
Blockly
(1)
IT News
(1)
OpenAI
(1)
SE
(1)
W7
(1)
Writer
(1)
app inv2
(1)
dfs
(1)
vex vr sample
(1)
影像處理練習
(1)
黑白講
(1)
2010年3月29日 星期一
大數除法
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言