Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
70247 袁嘉蔓 打印每一趟冒泡排序 C++ Wrong Answer 1 MS 348 KB 306 2024-04-14 11:12:17

Tests(0/3):


Code:

#include<bits/stdc++.h> using namespace std; int main(){ int n[20000]={0}; int a; cin>>a; for(int i=0;i<a;i++){ cin>>n[i]; } for (int i=0;i<a-1;i++){ for(int j=0;j<a-1-i;j++){ if(n[j]>n[j+1]){ swap(n[j],n[j+1]); cout<<n[j]<<" "; } } } return 0; }


Run Info:

------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 3 2 1 3 2 1 2 1 1