标签:
1 #include"iostream" 2 #define N 10 3 using namespace std; 4 void excha(int &a,int &b); 5 int main(){ 6 int a[N]={1,3,2,4,5,6,7,8,9,0}; 7 int i,j,min; 8 for(int i=1;i<N;i++){ 9 10 11 for(int j=i;j>0&&(a[j]<a[j-1]);j--){ 12 excha(a[j],a[j-1]); 13 } 14 } 15 for(int i=0;i<N;i++){ 16 cout<<a[i]<<" "; 17 } 18 return 0; 19 } 20 void excha(int &a,int &b){ 21 int c; 22 c=a; 23 a=b; 24 b=c; 25 }
标签:
原文地址:http://www.cnblogs.com/hutonm/p/5240392.html