| Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
|---|---|---|---|---|---|---|---|---|
| 147765 | 谢绍澜 | 优化冒泡排序 | C++ | Accepted | 4 MS | 280 KB | 714 | 2026-02-07 15:30:27 |
#include<iostream> // cin\cout\endl #include<cstdio> //scanf()\printf() #include<cstring> // strcpy()\strcat()\strcmp()\strlen()\memset() #include<vector> #include<cmath> //sqrt()\pow()\abs()\ceil()\floor()\max()\min() using namespace std; int main(){ int n,t,s; cin>>n; int a[n+1]; for(int i=1;i<=n;i++){ cin>>a[i]; } for(int i=1;i<n;i++){ s=0; for(int j=1;j<n-i+1;j++){ if(a[j]<a[j+1]){ t=a[j]; a[j]=a[j+1]; a[j+1]=t; s=1; } } if(s==0) break; } for(int i=1;i<=n;i++){ cout<<a[i]<<" "; } return 0; }