清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>
//冒泡排序
#include<iostream>
#include<array>
using namespace std;
template<class T>
void bubble_sort(T&, int);
int main()
{
array<int, 10> arr = {1,4,3,2,6,5,8,7,9,0};
bubble_sort(arr, arr.size());
for(auto i:arr)
cout << i << endl;
return 0;
}
template<class T>
void bubble_sort(T& arr, int cont)
{
for(int i = 0; i < cont; i++)
{
for(int j = 0; j < cont-i-1; j++)
{
if(arr[j] > arr[j+1])
{
swap(arr[j], arr[j+1]);
}
}
}
}