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源码 ...
随机推荐
- Ubuntu16.04.3安装以及简单配置使用
1. 官网下载ubuntu16.04.3的iso 2.上传至esxi 3. 中文安装界面有问题,使用english进行安装. 4. server版本的应该不带gui的界面进行安装... 5.使用非ro ...
- schema举例一
schema举例一: <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs=& ...
- Quartz.Net—MisFire
什么是misfire misfire就是哑火,就是trigger没有得到正常的触发. 1.所有的threadpool都在工作,而且工作时间很长,导致trigger没有threadpool去执行. 2. ...
- jdk1.8 HashMap红黑树操作详解-putTreeVal()
以前也看过hashMap源码不过是看的jdk1.7的,由于时间问题看的也不是太深入,只是大概的了解了一下他的基本原理:这几天通过假期的时间就对jdk1.8的hashMap深入了解了下,相信大家都是对红 ...
- redis map存储的注意点
- Redis之发布订阅
一 什么是发布订阅 发布订阅模式又叫观察者模式,它定义对象间的一种一对多的依赖关系,当一个对象的状态发生改变时,所有依赖它的对象都将得到通知 Redis 发布订阅(pub/sub)是一种消息通信模式: ...
- MT【234】正方形染色(二)
有$n$个正方形排成一行,今用红,白,黑三种颜色给这$n$个正方形染色,每个正方形只能染一种颜色.如果要求染这三种颜色的正方形都是偶数个,问有多少种不同的染色方法. 解答: 设有$a_n$种不同的染法 ...
- MT【219】构造二次函数
(2012北大保送)已知$f(x)$是二次函数,且$a,f(a),f(f(a)),f(f(f(a)))$是正项等比数列;求证:$f(a)=a$ 构造二次函数$f(x)=qx$,则$a,f(a),f(f ...
- 自学Aruba2.2-Aruba Web UI --Monitoring面板介绍
点击返回:自学Aruba之路 自学Aruba2.2-Aruba Web UI --Monitoring面板介绍 1. Monitoring面板-NETWORK Network Summary ...
- luogu1966 火柴排队(离散化+树状数组)
由于是一个二次函数的关系,所以易证应该尽量让两组的顺序相同 然后就离散化乱搞几发,最后就变成了求逆序对的数量了 #include<bits/stdc++.h> #define pa pai ...