zoukankan      html  css  js  c++  java
  • 冒泡排序


    //冒泡排序
    #include "stdafx.h"
    using namespace std;
    #include<vector>
    #include<string>

    class Solution
    {
    public:

        static int* bubbleSort(int* array, int len)
        {
            
            for (int i = 0; i < len; i++)
            {
                for (int j = 0; j < len - 1 - i; j++)
                {
                    if (array[j + 1] < array[j])
                    {
                        int temp = array[j + 1];
                        array[j + 1] = array[j];
                        array[j] = temp;
                    }
                }

            }
            return array;
        }




    };


    int main()
    {
        int aa[]  = { 1, 5, 6, 7, 2, 3 };
        Solution sou;
        sou.bubbleSort(aa, 6);
        return 1;
    }

    天天向上
  • 相关阅读:
    css 旋转
    html 旋转
    链表和数组的区别
    hashmap
    【java开发系列】—— 自定义注解
    java不确定参数个数方法例子
    mysql 删除
    linux下常用命令
    php的几种算法(转载)
    数据容器
  • 原文地址:https://www.cnblogs.com/hg07/p/12733102.html
Copyright © 2011-2022 走看看