摘要:
#include <iostream>using namespace std;void bubbleSort(int a[],int n){ bool flag = true; for (int i = n - 1; flag && i > 0; i--) { flag = false; for (int j = 0; j < i; j++) { if (a[j] > a[j + 1]) { int temp = a[j]; a[j... 阅读全文
摘要:
#include <iostream>using namespace std;void insertSort(int a[], int n) { for (int i = 1; i < n; i++) { int temp = a[i]; int j = i - 1; for (; j >= 0 && a[j] > temp; j--) { a[j + 1] = a[j]; } a[j + 1] = temp; }// for (int i = 1; i < n... 阅读全文