国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 課堂 > 技術開發(fā) > 正文

VBA中實現(xiàn)選擇排序算法

2023-06-15 12:14:57
字體:
來源:轉載
供稿:網友

Public Sub SelectionSort(ByRef lngArray() As Long)
    Dim iOuter As Long
    Dim iInner As Long
    Dim iLBound As Long
    Dim iUBound As Long
    Dim iTemp As Long
    Dim iMax As Long

    iLBound = LBound(lngArray)
    iUBound = UBound(lngArray)

    '選擇排序
    For iOuter = iUBound To iLBound + 1 Step -1

        iMax = 0

        '得到最大值得索引
        For iInner = iLBound To iOuter
            If lngArray(iInner) > lngArray(iMax) Then iMax = iInner
        Next iInner

        '值交換
        iTemp = lngArray(iMax)
        lngArray(iMax) = lngArray(iOuter)
        lngArray(iOuter) = iTemp

    Next iOuter
End Sub

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 怀化市| 灵寿县| 江川县| 邢台县| 西乌珠穆沁旗| 察哈| 磐石市| 康定县| 任丘市| 巴彦县| 磴口县| 县级市| 普宁市| 南乐县| 淮南市| 库车县| 南丹县| 上高县| 沁源县| 江山市| 周至县| 孟津县| 兴安县| 顺平县| 寻甸| 刚察县| 平远县| 安徽省| 称多县| 珠海市| 洛浦县| 嘉荫县| 瓮安县| 晋城| 建平县| 桂平市| 德兴市| 泰来县| 蓬安县| 闵行区| 西盟|