Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
114781 | 陈昊然 | 打印每一趟选择排序 | C++ | Accepted | 1 MS | 268 KB | 386 | 2025-03-23 14:28:26 |
#include<bits/stdc++.h> using namespace std; int a[2001]; int n; int main() { cin>>n; for(int i=0; i<=n-1; i++) { cin>>a[i]; } for(int i=0; i<=n-2; i++) { int m=i; for(int u=i; u<=n-1; u++) { if(a[u]<a[m]) { m=u; } } if(i!=m) { swap(a[i],a[m]); } for(int i=0; i<=n-1; i++) { cout<<a[i]<<" "; } cout<<endl; } return 0; }