#include
#include
#include
#include
using namespace std;
const int maxn=100;//要生成的数组的大小
const int N=1000;//生成0~N-1之间的数
int a[maxn];
int main(){
srand((unsigned)time(NULL));/*播种子*/
for(int i=0;ia[i] = rand()%N;
}
printf("Before sorted: ");
for(int i=0;iprintf("\n");
printf("after sorted: ");
sort(a,a+maxn);
for(int i=0;iprintf("\n");
return 0;
}
运行结果: