| Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
|---|---|---|---|---|---|---|---|---|
| 84716 | 游四鑫 | 打印每一趟冒泡排序 | C++ | Wrong Answer | 1 MS | 268 KB | 460 | 2024-07-16 11:36:58 |
#include<iostream> using namespace std; int main(){ int t=0,n; int a[10000]; bool f=1; cin>>n; for(int k=0;k<n;k++){ cin>>a[k]; } for(int i=0;i<n;i++){ f=0; for(int j=n-1;j>i;j--){ if(a[j]<a[j-1]){ t=a[j]; a[j]=a[j-1]; a[j-1]=t; f=1; } } if(f==0){ break; } for(int r=0;r<n;r++){ cout<<a[r]<<' '; } 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-----
1 5 4 3 2 1 2 5 4 3 1 2 3 5 4 1 2 3 4 5