51Nod--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
源代码:
 
   
<span style="font-size:18px;">#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<deque>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<iomanip>
#include<cstdlib>
#include<cmath>
#include<sstream>
#include<ctime>
using namespace std;

int ans[50005];

int cmp(const int &a,const int &b)
{
    return a < b;
}

int main()
{
    int n;
    int i;
    scanf("%d",&n);
    for(i = 0; i < n; i++)
        scanf("%d",&ans[i]);
    //sort(ans,ans+n);//默认从小到大
    sort(ans,ans+n,cmp);
    for(i = 0; i < n; i++)
        printf("%d\n",ans[i]);
	return 0;
}
</span>


转载于:https://www.cnblogs.com/lemonbiscuit/p/7776103.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值