Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
101395 | 杨一诺 | 优化冒泡排序 | C++ | Accepted | 8 MS | 280 KB | 345 | 2024-12-15 10:48:35 |
#include<bits/stdc++.h> using namespace std; const int MAXN=2000; int a[MAXN],c; int main(){ int n; cin>>n; for(int i=0;i<n;i++){ cin>>a[i]; } for(int i=0;i<n-1;i++){ for(int j=0;j<n-1-i;j++){ if(a[j]<a[j+1]){ swap(a[j],a[j+1]); c=1; } } } for(int i=0;i<n;i++){ cout<<a[i]<<' '; } return 0; }