[C++] 纯文本查看 复制代码 #include<bits/stdc++.h>
using namespace std;
int a[100],temp=0,j;
int main()
{
srand(time(0));
for(int i=0;i<10;i++)
{
a[i]=rand();
cout<<a[i];
cout<<endl;
}
for(int i=0;i<10;i++)
{
temp=i;//temp++
for(j=i+1;j<10;j++)
{
if(a[temp]>a[j])
{
temp=j;
}
}
swap(a[i],a[temp]);
}
for(int i=0;i<10;i++)
{
cout<<a[i]<<" ";
}
} |