Skip to main content

  | मौसम…

411 समाचार
Public archive edition · Attributed source reporting with original dates · AI drafts are excluded

411 REFERENCE · Wikibooks

Algorithms/Find maximum/visual basic method 2

Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.

Public Function Divide_n_Conquer(ByVal MyNums() As Integer) As Integer If myNums.Length = 0 Then Return 0 End If If myNums.Length = 1 Then Return myNums(0) End If If myNums.Length = 2 Then If myNums(0) > myNums(1) Then Return myNums(0) Else Return myNums(1) End If End If Dim aryA(myNums.Length / 2) As Integer Dim aryB(myNums.Length - aryA.Length) As Integer Dim i As Integer Dim loopindex As Integer = 0 For i = 0 To myNums.Length / 2 aryA(i) = myNums(i) loopindex += 1 Next Dim intK As Integer = 0 For i = aryA.Length To myNums.Length - 1 aryB(intK) = myNums(loopindex) loopindex = loopindex + 1 intK = intK + 1 Next Dim intM As Integer = 0 Dim intN As Integer = 0 intM = FindMax(aryA) intN = FindMax(aryB) If intM > intN Then Return intM Elselen(a) Return intN End If End Function