国产探花免费观看_亚洲丰满少妇自慰呻吟_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ā)表
主站蜘蛛池模板: 安远县| 兴仁县| 黎平县| 新化县| 恭城| 农安县| 河间市| 西乌| 大港区| 兰溪市| 文昌市| 长乐市| 浮山县| 吉安市| 丹凤县| 峡江县| 庆云县| 开封县| 遵义县| 安多县| 碌曲县| 白河县| 华池县| 当雄县| 八宿县| 太和县| 香河县| 荃湾区| 许昌县| 舒兰市| 华容县| 关岭| 天等县| 平泉县| 分宜县| 峨眉山市| 奇台县| 晴隆县| 资溪县| 长治县| 遂溪县|