#include<iostream>
using namespace std;
int main()
{
int arr[] = { 1,4,6,2,7,9,5,3 };
cout << "冒泡排序前:";
for (int i = 0; i < 8; i++)
{
cout << arr[i] << " ";
}
cout << endl;
//开始冒泡排序
for (int i = 0; i < 8-1; i++)
{
for (int b =0;b<8-i-1;b++)
{
if (arr[b] > arr[b + 1])
{
int temp = arr[b];
arr[b] = arr[b + 1];
arr[b + 1] = temp;
}
}
}
//输出
cout << "冒泡排序后:";
for (int i = 0; i < 8; i++)
{
cout << arr[i] << " ";
}
cout << endl;
system("pause");
return 0;
}