Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
106865 | 胡海峰老师 | 初级冒泡排序 | C++ | Accepted | 5 MS | 280 KB | 746 | 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 */