首页 > 代码库 > 1154. Easy sort
1154. Easy sort
#include<iostream>
#include<cmath>
#include<iomanip>
#include<algorithm>
using namespace std;
int main(){
int t;
cin>>t;
while(t--){
int n;
cin>>n;
int a[n];
for(int i =0 ;i<n;i++){
int c;
cin>>c;
a[i] = c;
}
for(int i=0;i<n;i++){
for(int j=i;j<n;j++){
int tem;
if(a[i]>a[j]){
tem = a[j];
a[j]=a[i];
a[i]=tem;
}
}
}
for(int i =0 ;i<n;i++){
cout<<a[i]<<endl;
}
}
return 0;
}
#include<iostream>
#include<cmath>
#include<iomanip>
#include<algorithm>
using namespace std;
int main(){
int t;
cin>>t;
while(t--){
int n;
cin>>n;
int a[n];
for(int i =0 ;i<n;i++){
int c;
cin>>c;
a[i] = c;
}
sort( a,a+n, less<int>() );
for(int i=0;i<n;i++){
cout<<a[i]<<endl;
}
}
return 0;
}
1154. Easy sort