冒泡排序


//冒泡排序
#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;
}

天天向上
原文地址:https://www.cnblogs.com/hg07/p/12733102.html