51Nod--1018排序
第1行:整数的数量N(1 <= N <= 50000)
第2 - N + 1行:待排序的整数(-10^9 <= A[i] <= 10^9)
共n行,按照递增序输出排序好的数据。
5
5
4
3
2
1
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排序的更多相关文章
- 51nod 1018 排序
1018 排序 基准时间限制:1 秒 空间限制:131072 KB 分值: 0 难度:基础题 收藏 关注 给出N个整数,对着N个整数进行排序 Input 第1行:整数的数量N(1 <= N ...
- (快排)51NOD 1018 排序
给出N个整数,对着N个整数进行排序 Input 第1行:整数的数量N(1 <= N <= 50000) 第2 - N + 1行:待排序的整数(-10^9 <= A[i] < ...
- 51Nod 2020 排序相减
题目链接:https://www.51nod.com/onlineJudge/questionCode.html#!problemId=2020 思路:排序 水水 #include<iostre ...
- 【51NOD-0】1018 排序
[算法]排序 #include<cstdio> #include<algorithm> using namespace std; ]; int main() { scanf(& ...
- 51nod 2020 排序相减(暴力解法)
题目: 代码: #include <bits\stdc++.h> using namespace std; int trim(int x){ ]; ;i < ; i++){ a[i] ...
- 51nod 1589 移数博弈【桶排序+链表】
1589 移数博弈 基准时间限制:1 秒 空间限制:262144 KB 分值: 80 难度:5级算法题 小A和小B在玩一个游戏. 他们拥有一个数列. 小A在该数列中选择出最大的那个数,然后移出该数 ...
- 51nod 1095 Anigram单词【hash/map/排序/字典树】
1095 Anigram单词 基准时间限制:1 秒 空间限制:131072 KB 分值: 10 难度:2级算法题 收藏 关注 一个单词a如果通过交换单词中字母的顺序可以得到另外的单词b,那么定义b ...
- 51nod 1874 字符串排序
1874 字符串排序 基准时间限制:1 秒 空间限制:131072 KB 分值: 5 难度:1级算法题 收藏 关注 定义一个字符串的无序度为所有位置后面的字母比该位置的字母小的总数之和.比如&q ...
- 51nod 1402 最大值 3级算法题 排序后修改限制点 时间复杂度O(m^2)
代码: 题意,第一个数为0,相邻的数相差0或者1,有一些点有限制,不大于给定值,求这组数中可能的最大的那个数. 这题我们看一个例子:第5个数的限制为2 1 2 3 4 5 6 7 8 9 0 1 2 ...
随机推荐
- 数据帧CRC32校验算法实现
本文设计思想采用明德扬至简设计法.由于本人项目需要进行光纤数据传输,为了保证通信质量要对数据进行校验.在校验算法中,最简单最成熟的非CRC校验莫属了. 得出一个数的CRC校验码还是比较简单的: 选定一 ...
- java的集合框架set 和map的深入理解
Java的集合框架之Map的用法详解 Map有两种比较常用的实现:HashMap 和 TreeMap. HashMap: HashMap 也是无序的,也是按照哈希编码来排序的,允许使用null 值和n ...
- 读书笔记-你不知道的JS中-函数生成器
这个坑比较深 可能写完我也看不懂(逃 ES6提供了一个新的函数特性,名字叫Generator,一开始看到,第一反应是函数指针?然而并不是,只是一个新的语法. 入门 简单来说,用法如下: functio ...
- Ionic3 打包并签名Android-App
ionic cordova build android --prod --release 此时,在项目根目录中看下看到生成的apk文件:platforms\android\build\outputs\ ...
- poj 2566 Bound Found
Bound Found Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 4384 Accepted: 1377 Spe ...
- Leftmost Digit
Problem Description Given a positive integer N, you should output the leftmost digit of N^N. Input ...
- Nginx HTTP 核心模块
原文链接:http://blog.chinaunix.net/xmlrpc.php?r=blog/article&uid=17238776&id=2982697aio 语法:aio [ ...
- C# linq创建嵌套组
以下示例演示如何在 LINQ 查询表达式中创建嵌套组. 首先根据学生年级创建每个组,然后根据每个人的姓名进一步细分为小组. public void QueryNestedGroups() { var ...
- Lambda转sql部分代码保存
public class SqlExpressionTree { public string GetQuerySql<T>(Expression<Func<T, bool> ...
- 微信公众平台快速开发框架 For Core 2.0 beta –JCSoft.WX.Core 5.2.0 beta发布
写在前面 最近比较忙,都没有好好维护博客,今天拿个半成品来交代吧. 记不清上次关于微信公众号快速开发框架(简称JCWX)的更新是什么时候了,自从更新到支持.Net Framework 4.0以后基本上 ...