| Run ID | Author | Problem | Lang | Verdict | Time | Memory | Code Length | Submit Time |
|---|---|---|---|---|---|---|---|---|
| 59548 | teacher_wang | 排序-难度系数2 | C++ | Accepted | 0 MS | 248 KB | 747 | 2024-12-27 12:28:36 |
#include<bits/stdc++.h> using namespace std; int main(){ int a[6]; for(int i = 1; i <= 5; i ++) cin>>a[i]; for(int i = 2; i <= 5; i ++) { int temp = a[i]; //存储等待插入的元素 int index = i - 1; //每次和temp进行比较的元素位置 while(index >= 1) { if(a[index] >= temp) //找到一个合适位置 break; a[index+1] = a[index]; //往后移动 index --; //继续往前寻找位置 } a[index+1] = temp; } for(int i = 1; i <= 5; i ++) { cout<<a[i]; if(i < 5) cout<<","; } cout<<endl; return 0; }