{"id":1220,"date":"2024-08-05T08:00:00","date_gmt":"2024-08-05T00:00:00","guid":{"rendered":"http:\/\/www.wyrcad.com\/?p=1220"},"modified":"2024-07-17T16:09:10","modified_gmt":"2024-07-17T08:09:10","slug":"%e5%bf%ab%e9%80%9f%e6%8e%92%e5%ba%8f%e4%b8%8e%e5%86%92%e6%b3%a1%e6%8e%92%e5%ba%8f","status":"publish","type":"post","link":"https:\/\/www.wyrcad.com\/?p=1220","title":{"rendered":"\u5feb\u901f\u6392\u5e8f\u4e0e\u5192\u6ce1\u6392\u5e8f"},"content":{"rendered":"\n<p>Sub QuickSort(List() As Double)<br>Dim I As Double, J As Double, K As Double, b As Double<br>Dim L As Double, t As Double, r As Double, d As Double<br>Dim p(1 To 100) As Double<br>Dim w(1 To 100) As Double<br>K = 1<br>p(K) = LBound(List)<br>w(K) = UBound(List)<br>L = 1<br>d = 1<br>r = UBound(List)<br>Do<br>toploop:<br>If r &#8211; L &lt; 9 Then GoTo bubsort I = L J = r While J &gt; I<br>comp = comp + 1<br>If List(I) &gt; List(J) Then<br>swic = swic + 1<br>t = List(J)<br>oldx1 = List(J)<br>oldy1 = J<br>List(J) = List(I)<br>oldx2 = List(I)<br>oldy2 = I<br>newx1 = List(J)<br>newy1 = J<br>List(I) = t<br>newx2 = List(I)<br>newy2 = I<br>d = -d<br>End If<br>If d = -1 Then<br>J = J &#8211; 1<br>Else<br>I = I + 1<br>End If<br>Wend<br>J = J + 1<br>K = K + 1<br>If I &#8211; L &lt; r &#8211; J Then p(K) = J w(K) = r r = I Else p(K) = L w(K) = I L = J End If d = -d GoTo toploop bubsort: If r &#8211; L &gt; 0 Then<br>For I = L To r<br>b = I<br>For J = b + 1 To r<br>comp = comp + 1<br>If List(J) &lt;= List(b) Then b = J Next J If I &lt;&gt; b Then<br>swic = swic + 1<br>t = List(b)<br>oldx1 = List(b)<br>oldy1 = b<br>List(b) = List(I)<br>oldx2 = List(I)<br>oldy2 = I<br>newx1 = List(b)<br>newy1 = b<br>List(I) = t<br>newx2 = List(I)<br>newy2 = I<br>End If<br>Next I<br>End If<br>L = p(K)<br>r = w(K)<br>K = K &#8211; 1<br>Loop Until K = 0<br>End Sub<\/p>\n\n\n\n<p>Sub BubbleSort(List() As Double)<br>&#8216;Sorts an array using bubble sort algorithm<br>Dim First As Double, Last As Double<br>Dim I As Integer, J As Integer<br>Dim Temp As Double<\/p>\n\n\n\n<p>First = LBound(List)<br>Last = UBound(List)<br>For I = First To Last &#8211; 1<br>For J = I + 1 To Last<br>If List(I) &gt; List(J) Then<br>Temp = List(J)<br>List(J) = List(I)<br>List(I) = Temp<br>End If<br>Next J<br>Next I<br>End Sub<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Sub QuickSort(List() As Double)Dim I As Double, J As Do &hellip; <a href=\"https:\/\/www.wyrcad.com\/?p=1220\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">\u201c\u5feb\u901f\u6392\u5e8f\u4e0e\u5192\u6ce1\u6392\u5e8f\u201d<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[24,17],"class_list":["post-1220","post","type-post","status-publish","format-standard","hentry","category-bianchengyuandi","tag-vb","tag-biancheng"],"_links":{"self":[{"href":"https:\/\/www.wyrcad.com\/index.php?rest_route=\/wp\/v2\/posts\/1220","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wyrcad.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wyrcad.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wyrcad.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wyrcad.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1220"}],"version-history":[{"count":1,"href":"https:\/\/www.wyrcad.com\/index.php?rest_route=\/wp\/v2\/posts\/1220\/revisions"}],"predecessor-version":[{"id":1221,"href":"https:\/\/www.wyrcad.com\/index.php?rest_route=\/wp\/v2\/posts\/1220\/revisions\/1221"}],"wp:attachment":[{"href":"https:\/\/www.wyrcad.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1220"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wyrcad.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1220"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wyrcad.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1220"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}