1 #include<iostream>
 2 using namespace std;
 3 int main()
 4 {
 5     int temp = 0;
 6     int arr[6] = { 0,3,1,7,4,5 };
 7     for (int i = 0; i < 5; i++) {
 8         for (int j = 0; j < 5 - i; j++) {
 9             if (arr[j + 1] > arr[j]) {
10                 temp = arr[j];
11                 arr[j] = arr[j + 1];
12                 arr[j + 1] = temp;
13             }
14         }
15     }
16 
17     for (int i = 0; i < 6; i++) {
18         cout << arr[i] << endl;
19     }
20     
21     system("pause");
22     return 0;
23 }

 

posted on 2022-11-09 14:29  小凉拖  阅读(44)  评论(0编辑  收藏  举报