#include <iostream> #include <cstdlib> #include <ctime> using namespace std; int main(int argc, char** argv) { int a[10]; int m; srand(time(0)); for(int i=0;i<10;i++){ m=rand()%1000; cout<<m<<" "; a[i]=m; } int o; for(int j=0;j<10;j++){ for(int l=j;l<10;l++){ if(a[j]>a[l]){ o=a[j]; a[j]=a[l]; a[l]=o; } } } for(int i=0;i<10;i++){ cout<<a[i]<<endl; } return 0; }
标签:std,main,排序,int,随机数,include From: https://www.cnblogs.com/wangyueshuo/p/17463944.html