| Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
|---|---|---|---|---|---|---|---|---|
| 129874 | 林嘉乐 | 打印每一趟冒泡排序 | C++ | Wrong Answer | 2 MS | 280 KB | 478 | 2025-09-06 17:14:46 |
#include<bits/stdc++.h> using namespace std; int main() { int a[2001]={},n,t; 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]){ t=a[j]; a[j]=a[j+1]; a[j+1]=t; } for(int i=0;i<n-1;i++){ cout<<a[i]<<" "; } cout<<a[n-1]<<endl; } for(int i=0;i<n-1;i++){ cout<<a[i]<<" "; } cout<<a[n-1]<<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-----
4 5 3 2 1 4 3 5 2 1 4 3 2 5 1 4 3 2 1 5 4 3 2 1 5 3 4 2 1 5 3 2 4 1 5 3 2 1 4 5 3 2 1 4 5 2 3 1 4 5 2 1 3 4 5 2 1 3 4 5 1 2 3 4 5 1 2 3 4 5