#include <iostream>
#include <string>
using namespace std;
int main(){
int aa[] = {5,9,6,2,4,3,7,6,8,1};
int b = sizeof(aa)/sizeof(aa[0]);
int temp;
int c = b;
cout <<"排序前\t";
for (int i = 0; i < b; i++)
{
cout <<aa[i]<<"\t";
}
for (int i = 0; i < b-1; i++)
{
for (int i = 0; i < c-1; i++) // 每次都找到一个最大数
{
if (aa[i] >= aa[i+1])
{
temp = aa[i];
aa[i] = aa[i+1];
aa[i+1] = temp;
}
}
c--; // 已经找到一个数了,下一次比较次数减一
}
cout <<"\n排序后\t";
for (int i = 0; i < b; i++)
{
cout <<aa[i]<<"\t";
}
}