冒泡排序,迈开跑路第一步
#include<iostream>
#include<string>
using namespace std;
int main() {
int arr[] = { 7,8,6,3,2,4,8,6,5,1 };
int len = sizeof(arr) / sizeof(arr[0]);
int temp = 0;
for (int i = 0; i < len-1; i++) {
for (int j = 0; j < len-i-1; j++) {
if (arr[j] > arr[j + 1]) {
temp = arr[j];
arr[j] = arr[j+1];
arr[j+1] = temp;
}
}
}
for (int i = 0; i < len; i++) {
cout << arr[i] << endl;
}
system("pause");
return 0;
}