冒泡排序
#include <bits/stdc++.h> using namespace std; int main(int argc, char** argv) { srand(time(0)); int a=rand()%1001; int list[10]; for(int i=0;i<10;i++){ a=rand()%1001; list[i]=a; cout<<setw(5)<<list[i]<<endl; } cout<<"**************************"<<endl; int num=0; for(int i=0;i<10;i++){ for(int j=0;j<10;j++){ if(list[i]<list[j]){ num=list[i]; list[i]=list[j]; list[j]=num; } } } for(int i=0;i<10;i++){ cout<<list[i]<<endl; } return 0; }