Simple Sort
题目描述
You are given an unsorted array of integer numbers. Your task is to sort this array and kill possible duplicated elements occurring in it.
输入描述:
For each case, the first line of the input contains an integer number N representing the quantity of numbers in this array(1≤N≤1000). Next N lines contain N integer numbers(one number per each line) of the original array.
输出描述:
For each case ,outtput file should contain at most N numbers sorted in ascending order. Every number in the output file should occur only once.
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
int a[1000], b[1000];
int n;
while(cin >> n){
for(int i = 0; i < n; i++){
cin >> a[i];
}
sort(a, a + n);
b[0] = a[0];
int k = 1;
for(int i = 1; i < n; i++){
if(a[i] > a[i - 1]) {
b[k] = a[i];
k++;
}
}
for(int i = 0; i < k; i++){
cout << b[i] << " ";
}
}
return 0;
}
Simple Sort的更多相关文章
- 计算 TP90TP99TP...
what-do-we-mean-by-top-percentile-or-tp-based-latency tp90 is a minimum time under which 90% of requ ...
- 东大OJ-快速排序
1236: Simple Sort 时间限制: 1 Sec 内存限制: 128 MB 提交: 195 解决: 53 [提交][状态][讨论版] 题目描述 You are given n ...
- MapReduce应用案例--简单排序
1. 设计思路 在MapReduce过程中自带有排序,可以使用这个默认的排序达到我们的目的. MapReduce 是按照key值进行排序的,我们在Map过程中将读入的数据转化成IntWritable类 ...
- Java theory and practice
This content is part of the series: Java theory and practice A brief history of garbage collection A ...
- Studious Student Problem Analysis
(http://leetcode.com/2011/01/studious-student-problem-analysis.html) You've been given a list of wor ...
- 配置Tree Shaking来减少JavaScript的打包体积
译者按: 用Tree Shaking技术来减少JavaScript的Payload大小 原文: Reduce JavaScript Payloads with Tree Shaking 译者: Fun ...
- Delphi 二维码产生和扫描
Zint用于产生二维码. Zxing用读取二维码. VFrames.pas和VSample.pas用于摄像头. 另附带摄像头相关的类库,也可用开源的dspack也可用于摄像头的需求. 以上为开源的信息 ...
- JavaScript性能优化之摇树
作者|Jeremy Wagner译者|薛命灯 现代 Web 应用程序可能会变得非常巨大,特别是它们的 JavaScript 部分.HTTP Archive 网站的数据显示,截至 2018 年中,传输到 ...
- 按照自己的思路研究Spring AOP源码【2】
目录 问题的提出 哪一步导致了顺序的改变 AbstractAdvisorAutoProxyCreator.sortAdvisors()方法 总结 问题的提出 上面这篇文章介绍了Spring AOP源码 ...
随机推荐
- 终端curl调用jenkins自动化持续集成
1.curlcurl是利用URL语法在命令行方式下工作的开源文件传输工具.它被广泛应用在Unix.多种Linux发行版中,并且有DOS和Win32.Win64下的移植版本. 1.1 获取url指向的页 ...
- charCodeAt与fromCharCode
charCodeAt() 方法可返回指定位置的字符的 Unicode 编码 这个返回值是 0 - 65535 之间的整数. stringObject.charCodeAt(index) /* a-z ...
- [转帖]UML各种图总结-精华
UML各种图总结-精华 https://www.cnblogs.com/jiangds/p/6596595.html 之前自己以为画图很简单 不需要用心学 现在发现自己一直没有学会一些基础的知识 能力 ...
- ACDsee的安装过程
http://www.ddooo.com/softdown/76175.htm ACDSee 18中文版安装教程: 1.ACDSee 18分为32位和64位版本,我们先选择合适系统的中文版本开始安装, ...
- U9财务体系
- mysql 8.0,运行springboot项目配置:
1.修改pom.xml <dependency> <groupId>mysql</groupId> <artifactId>mysql-connecto ...
- DOM 操作技术【JavaScript高级程序设计第三版】
很多时候,DOM 操作都比较简明,因此用JavaScript 生成那些通常原本是用HTML 代码生成的内容并不麻烦.不过,也有一些时候,操作DOM 并不像表面上看起来那么简单.由于浏览器中充斥着隐藏的 ...
- semantic segmentation with deeplearning
a 2017 guide to semantic segmentation with deep learning paper: http://blog.qure.ai/notes/semantic-s ...
- Mysterious Bacteria LightOJ - 1220
题意: 给出一个数x 求 x = bp 的p的最大值 解析: 算术基本定理 分解质因数 任何一个数x都可以表示为 x == p1a1 * p2a2 * ````` * pnan 即 b ...
- day5 模拟购物车程序
#__author__: Administrator #__date__: 2018/7/11 print(''' ======本公司退出以下产品======= 1.bicycle---------- ...