基准时间限制: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>

51Nod--1018排序的更多相关文章

  1. 51nod 1018 排序

    1018 排序 基准时间限制:1 秒 空间限制:131072 KB 分值: 0 难度:基础题  收藏  关注 给出N个整数,对着N个整数进行排序 Input 第1行:整数的数量N(1 <= N  ...

  2. (快排)51NOD 1018 排序

    给出N个整数,对着N个整数进行排序   Input 第1行:整数的数量N(1 <= N <= 50000) 第2 - N + 1行:待排序的整数(-10^9 <= A[i] < ...

  3. 51Nod 2020 排序相减

    题目链接:https://www.51nod.com/onlineJudge/questionCode.html#!problemId=2020 思路:排序 水水 #include<iostre ...

  4. 【51NOD-0】1018 排序

    [算法]排序 #include<cstdio> #include<algorithm> using namespace std; ]; int main() { scanf(& ...

  5. 51nod 2020 排序相减(暴力解法)

    题目: 代码: #include <bits\stdc++.h> using namespace std; int trim(int x){ ]; ;i < ; i++){ a[i] ...

  6. 51nod 1589 移数博弈【桶排序+链表】

    1589 移数博弈 基准时间限制:1 秒 空间限制:262144 KB 分值: 80 难度:5级算法题   小A和小B在玩一个游戏. 他们拥有一个数列. 小A在该数列中选择出最大的那个数,然后移出该数 ...

  7. 51nod 1095 Anigram单词【hash/map/排序/字典树】

    1095 Anigram单词 基准时间限制:1 秒 空间限制:131072 KB 分值: 10 难度:2级算法题  收藏  关注 一个单词a如果通过交换单词中字母的顺序可以得到另外的单词b,那么定义b ...

  8. 51nod 1874 字符串排序

    1874 字符串排序  基准时间限制:1 秒 空间限制:131072 KB 分值: 5 难度:1级算法题  收藏  关注 定义一个字符串的无序度为所有位置后面的字母比该位置的字母小的总数之和.比如&q ...

  9. 51nod 1402 最大值 3级算法题 排序后修改限制点 时间复杂度O(m^2)

    代码: 题意,第一个数为0,相邻的数相差0或者1,有一些点有限制,不大于给定值,求这组数中可能的最大的那个数. 这题我们看一个例子:第5个数的限制为2 1 2 3 4 5 6 7 8 9 0 1 2 ...

随机推荐

  1. 视频加载logo 2

    推荐这个网站 http://www.flaticon.com/ http://www.flaticon.com/search?word=spinner  旋转图标 http://www.flatico ...

  2. 浅析Entity Framework Core中的并发处理

    前言 Entity Framework Core 2.0更新也已经有一段时间了,园子里也有不少的文章.. 本文主要是浅析一下Entity Framework Core的并发处理方式. 1.常见的并发处 ...

  3. angular控制器常用的4种通信方式

    首先概括一下angular控制器通信的4种方式: 作用域继承. 通过$scope广播事件. 事件发射器模块. 服务. 1.作用域的继承 子作用域可以访问声明在它们的祖先作用域中的变量和函数. < ...

  4. input框内的单引号,双引号转译

    主要是在后台传前端之前先把变量值替换单引号双引号成转译付. $bianlian是要替换的变量 两种方法 1.php后台输出值先转译 //双引号替换成转译符 $bianlian=preg_replace ...

  5. mysql服务处理流程

    先把错误日志定位 就是找的错误日志 然后必要的时候 重新启动服务器 排除其他的干扰 把错误日志 挪到旧文件 清空错误日志 然后试着启动 看干净的错误日志 然后 问题就解决了

  6. Queuing(以前写的没整理)

    Queuing Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Subm ...

  7. Turn the corner

    Turn the corner Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Tot ...

  8. 跨域 Ajax 其他可选技术 异步

    使用image pings 最早的跨域方法之一就是使用这个,任何域的<img>和<script>元素都可以随便加载. var img = new Image(); img.on ...

  9. threejs 组成的3d管道,寻最短路径问题

    threejs 里面的3d管道的每个节点ID是唯一的,且对应x,y,z坐标.那么当需要从A点到B点的时候,可能出现有多条路径可走,此时便需要求出最短行走路径,因此用到一个寻路径算法.我们将问题简化如下 ...

  10. 用户需求与NABCD分析

    用户需求与NABCD分析 目录 项目简介 用户需求分析 调研途径 问卷情况说明 问卷反馈与分析 NABCD分析 Need 需求 Approach 途径 Benefit 好处 Competitors 竞 ...