Run ID:106865

提交时间:2025-01-16 20:27:12

#include <iostream> using namespace std; int a[2001]; //2000个左右的数 int main () { int m; cin>>m; for(int i=0;i<m;i++) cin>>a[i]; for(int i=0;i<m-1;i++) for(int j=0;j<m-i-1;j++) { if(a[j]<a[j+1]) { int tmp=a[j]; a[j] =a[j+1]; a[j+1] = tmp; } } for(int i=0;i<m;i++) cout<<a[i]<<" "; return 0; } /* Input 10 5 3 2 4 1 6 10 8 9 7 [5 3] 2 4 1 6 10 8 9 7 5 [3 2] 4 1 6 10 8 9 7 5 3 [2 4] 1 6 10 8 9 7 √ 5 3 4 [2 1] 6 10 8 9 7 5 3 4 2 [1 6] 10 8 9 7 √ 5 3 4 2 6 [1 10] 8 9 7 √ 5 3 4 2 6 10 [1 8] 9 7 √ 5 3 4 2 6 10 8 [1 9] 7 √ 5 3 4 2 6 10 8 9 1 7 √ 5 3 4 2 6 10 8 9 7 【1】 最小值 (泡泡) Output 10 9 8 7 6 5 4 3 2 1 */