Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
70305 殷震轩 打印每一趟冒泡排序 C++ Wrong Answer 1 MS 276 KB 381 2024-04-14 11:33:28

Tests(2/3):


Code:

#include <bits/stdc++.h> using namespace std; int a[2000],n,o=0; int main () { 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]) { o=1; swap(a[j],a[j+1]); } } for(int i=0; i<n; i++) { cout<<a[i]<<" "; } cout<<endl; if(o==0){ break; } } return 0; }


Run Info:

------Input------
6 1 2 3 4 5 6
------Answer-----
1 2 3 4 5 6 1 2 3 4 5 6 1 2 3 4 5 6 1 2 3 4 5 6 1 2 3 4 5 6
------Your output-----
1 2 3 4 5 6