| Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
|---|---|---|---|---|---|---|---|---|
| 70269 | 殷震轩 | 优化冒泡排序 | C++ | Accepted | 4 MS | 288 KB | 366 | 2024-04-14 11:18:25 |
#include <bits/stdc++.h> using namespace std; int a[2000],n,o=0; int main (){ cin>>n; for(int i=0;i<n;i++){ cin>>a[i]; } for(int i=0;i<n;i++){ for(int j=0;j<n-1-i;j++){ if(a[j]<a[j+1]){ o=1; swap(a[j],a[j+1]); } } if(o==0){ break; } } for(int i=0;i<n;i++){ cout<<a[i]<<" "; } return 0; }