Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
157235 陈骏睿 打印每一趟选择排序 C++ Wrong Answer 1 MS 276 KB 423 2026-07-21 10:46:46

Tests(0/4):


Code:

#include<bits/stdc++.h> using namespace std; void print(vector<int>& a){ for(int i=0;i<a.size();++i){ if(i>0) cout<<" "; cout<<a[i]; } cout<<endl; } int main(){ int n; cin>>n; vector<int> a(n); for(int i=0;i<n;++i){ cin>>a[i]; } for(int i=1;i<n;++i){ int key = a[i]; int j=i-1; while(j>=0&&a[j]>key){ a[j+1]=a[j]; j--; } a[j+1]=key; print(a); } return 0; }


Run Info:

------Input------
5 5 8 5 2 9
------Answer-----
2 8 5 5 9 2 5 8 5 9 2 5 5 8 9 2 5 5 8 9
------Your output-----
5 8 5 2 9 5 5 8 2 9 2 5 5 8 9 2 5 5 8 9