Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
166517 C班-李梓韬 常用排序法 C++ 运行超时 95 1436 MS 648 KB 594 2024-08-19 14:45:55

Tests(19/20):


#include<bits/stdc++.h> using namespace std; int a[100001]; void InsertSort(int n) { for(int i=2; i<=n; i++){ int temp=a[i]; //temp为要插入的元素 int j=i-1; while(j>=1 && temp<a[j]) //从a[i-1]开始向前找比a[i]小的数 { a[j+1]=a[j]; //同时把数组元素向后移 --j; } a[++j]=temp; //插入 } } int main(){ int n; cin>>n; for(int i=1;i<=n;i++){ cin>>a[i]; } InsertSort(n); for(int i=1;i<=n;i++){ cout<<a[i]<<" "; } }


测评信息: