dream911543 2018-01-04 18:54:53
点我顶贴
收藏
删除
#include<iostream>
#include<stdlib.h>
#include<time.h>
using namespace std;
int main(){
int N;
cin>>N;
int a[N];
srand((unsigned)time(NULL));
for(int i=0;i<N;i++){
a[i]=rand()%1000;
cout<<a[i]<<" ";
}
cout<<endl;
for(int i=0,j=1;j<N;j++,i=0){
for(;i<j;i++){
if(a[j]<a[i]){
int t;
t=a[i];
a[i]=a[j];
a[j]=t;
}
}
}
for(int i=0;i<N;i++){
cout<<a[i]<<" ";
}
return 0;
}