#include<iostream> #include<string> using namespace std; #define day 7 //冒泡排序 void ArrSort(int *arr, int arrLength) { for (size_t i = 0; i < arrLength; i++) { for (size_t j = 0; j < arrLength -1-i; j++) { if (arr[j]>arr[j+1]) { int temp = arr[j]; arr[j] = arr[j + 1]; arr[j + 1] = temp; } } } } void PrintArr(int *arr,int len) { for (size_t i = 0; i < len; i++) { cout << arr[i] << endl; } } int main() { int arr[6] = {5,2,8,4,6,7}; int arrLength = sizeof(arr)/sizeof(arr[0]); PrintArr(arr, arrLength); cout << " " << endl; ArrSort(arr, arrLength); PrintArr(arr, arrLength); system("pause"); return 0; }