Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
85146 胡盛哲 打印每一趟插入排序 C++ Wrong Answer 0 MS 272 KB 368 2024-07-16 16:36:40

Tests(0/4):


Code:

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


Run Info:

------Input------
5 5 2 7 9 1
------Answer-----
2 5 7 9 1 2 5 7 9 1 2 5 7 9 1 1 2 5 7 9
------Your output-----
1 2 5 7 9