Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
113795 | 卢语涵 | 打印每一趟冒泡排序 | C++ | Wrong Answer | 0 MS | 268 KB | 523 | 2025-03-16 15:10:32 |
#include<iostream> using namespace std; int main(){ long long n,a[2000]; cin>>n; for(int i=0;i<n;i++){ cin>>a[i]; } for(int i=0;i<n-1;i++){ bool ph=true; for(int j=0;j<=n-2;j++){ if(a[j]<a[j+1]){ swap(a[j],a[j+1]); ph=false; } } if(ph==true){ break; } for(int i=0;i<n;i++){ cout<<a[i]<<" "; } cout<<endl; } return 0; }
------Input------
5 5 4 3 2 1
------Answer-----
4 3 2 1 5 3 2 1 4 5 2 1 3 4 5 1 2 3 4 5
------Your output-----