Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
106695 | 李谨睿 | 打印每一趟选择排序 | C++ | Accepted | 1 MS | 276 KB | 494 | 2025-01-16 15:09:05 |
#include<bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int a[n]; //1.数组的输入 for (int i = 0; i < n; i++) { cin >> a[i]; } int minindex,t; for(int o=0;o<=n-2;o++){ minindex=o; //记录器初始化为a[0]的下标0 for (int i = o; i < n; i++) { if (a[i] < a[minindex]) { minindex = i; } } t=a[o]; a[o]=a[minindex]; a[minindex]=t; for(int i=0;i<n;i++){ cout<<a[i]<<" "; } cout<<endl; } return 0; }