您的位置:首页 > 其它

51_nod 1018 排序

2017-04-24 11:10 260 查看
1018 排序

基准时间限制:1 秒 空间限制:131072 KB 分值: 0 难度:基础题 收藏 取消关注

给出N个整数,对着N个整数进行排序

Input

第1行:整数的数量N(1 <= N <= 50000)

第2 - N + 1行:待排序的整数(-10^9 <= A[i] <= 10^9)

Output

共n行,按照递增序输出排序好的数据。

Input示例

5

5

4

3

2

1

Output示例

1

2

3

4

5

代码:

#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstdlib>
long long a[50005];
int n;
//bool cmp(long long  a,long long b)
//{
//      return a<b;   //升序排列,如果改为return a>b,则为降序
//
//};
using namespace std;
void bsort(){
for(int i=0;i<=n-2;i++)
for(int j=i+1;j<=n-1;j++){
if(a[i]>a[j]){
long long temp;
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
}
int main(){

cin>>n;
for(int i=0;i<n;i++){
scanf("%I64d",&a[i]);

}
//sort(a,a+n);
bsort();

for(int i=0;i<n;i++){
printf("%I64d\n",a[i]);

}

return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: