Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
120195 殷佳雨萱 打印每一趟冒泡排序 C++ Wrong Answer 1 MS 264 KB 378 2025-05-24 11:58:07

Tests(0/3):


Code:

#include<bits/stdc++.h> using namespace std; int a[10000]; int main(){ int n; cin>>n; for(int i=1;i<=n;i++){ cin>>a[i]; } //冒泡排序法-下降法 for(int i=1;i<=n-1;i++){ //排序次数 for(int j=1;j<=n;j++){ if(a[j]>a[j+1]){ swap(a[j],a[j+1]); } } for(int i=1;i<=n;i++){ cout<<a[i]<<" "; } cout<<endl; } 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 0 3 2 1 0 4 2 1 0 3 4 1 0 2 3 4