标签:clu stream bsp color hang change 排序 span pre
冒泡排序
#include<iostream> using namespace std; int main() { int r[100]; int n,exchange,bound; cin>>n; for(int i=1; i<=n; i++) cin>>r[i]; exchange=n; while(exchange!=0) { bound=exchange; exchange = 0; for(int j=1; j<bound; j++) { if(r[j]>r[j+1]) { int temp; temp=r[j]; r[j]=r[j+1]; r[j+1]=temp; exchange=j; } } } for(int i=1; i<=n; i++) cout<<r[i]<<" "; return 0; }
标签:clu stream bsp color hang change 排序 span pre
原文地址:http://www.cnblogs.com/magicalzh/p/7928672.html