#include <IOSTREAM>
using namespace std;
int main(){
int temp;
int n;
cin>>n;
int *a=new int[n];

for(int k=0;k<n;k++){
cin>>a[k];
}
for(int b=0;b<n;b++){
cout<<a[b]<<" ";}
cout<<endl;


/*发一:
for(int i=n;i>1;i--){
for(int j=0;j<i-1;j++){
if(a[j]>a[j+1]){
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}

}
}*/
for(int i=0;i<n-1;i++){
for(int j=0;j<n-i-1;j++){
if(a[j]>a[j+1]){
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}

}
}
for(int c=0;c<n;c++){
cout<<a[c]<<" ";
}
return 0;
}

 

posted on 2016-11-18 18:45  smilesky314  阅读(293)  评论(0编辑  收藏  举报