题目描述

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的更多相关文章

  1. 计算 TP90TP99TP...

    what-do-we-mean-by-top-percentile-or-tp-based-latency tp90 is a minimum time under which 90% of requ ...

  2. 东大OJ-快速排序

    1236: Simple Sort 时间限制: 1 Sec  内存限制: 128 MB 提交: 195  解决: 53 [提交][状态][讨论版] 题目描述      You are given n ...

  3. MapReduce应用案例--简单排序

    1. 设计思路 在MapReduce过程中自带有排序,可以使用这个默认的排序达到我们的目的. MapReduce 是按照key值进行排序的,我们在Map过程中将读入的数据转化成IntWritable类 ...

  4. Java theory and practice

    This content is part of the series: Java theory and practice A brief history of garbage collection A ...

  5. Studious Student Problem Analysis

    (http://leetcode.com/2011/01/studious-student-problem-analysis.html) You've been given a list of wor ...

  6. 配置Tree Shaking来减少JavaScript的打包体积

    译者按: 用Tree Shaking技术来减少JavaScript的Payload大小 原文: Reduce JavaScript Payloads with Tree Shaking 译者: Fun ...

  7. Delphi 二维码产生和扫描

    Zint用于产生二维码. Zxing用读取二维码. VFrames.pas和VSample.pas用于摄像头. 另附带摄像头相关的类库,也可用开源的dspack也可用于摄像头的需求. 以上为开源的信息 ...

  8. JavaScript性能优化之摇树

    作者|Jeremy Wagner译者|薛命灯 现代 Web 应用程序可能会变得非常巨大,特别是它们的 JavaScript 部分.HTTP Archive 网站的数据显示,截至 2018 年中,传输到 ...

  9. 按照自己的思路研究Spring AOP源码【2】

    目录 问题的提出 哪一步导致了顺序的改变 AbstractAdvisorAutoProxyCreator.sortAdvisors()方法 总结 问题的提出 上面这篇文章介绍了Spring AOP源码 ...

随机推荐

  1. OA实例

    let express = require('express'); let consolidate = require('consolidate'); let bodyParser = require ...

  2. NF5280M4 安装 Win2016 的方法

    1. 前提条件, 硬盘大于2T, 2. 必须使用最新版本的 Win2016 首先 win2016的可用序列号 • Windows Server 数据中心 CB7KF-BWN84-R7R2Y-793K2 ...

  3. int ,Intege,String 三者之间的转换

    注:如果使用JDK5.0的话,JVM会自动完成装包解包的. 1.Integer转换成int的方法 Integer i = new Integer(10); int k = i.intValue();即 ...

  4. Android x86 下运行纯ARM版APP

    Android x86 默认不带houdini,运行纯ARM版会提示: 很抱歉,”xxxx”已停止运行 设置->应用兼容性->打开 终端模拟器 $ su# enable_nativebri ...

  5. const,static,volatile关键字的作用

    const关键字: 1.欲阻止一个变量被改变,可使用const,在定义该const变量时,需先初始化,以后就没有机会改变他了: 2.对指针而言,可以指定指针本身为const,也可以指定指针所指的数据为 ...

  6. ACdream1187-Rational Number Tree-模拟/找规律

    找到规律模拟就可以了,用DFS模拟很简洁,用循环模拟比较直观(大概吧) 注意输入输出用%llu,1ULL<<64=0!被这几个小问题卡了好久 #include <cstdio> ...

  7. hdu 6393 Traffic Network in Numazu (树链剖分+线段树 基环树)

    链接:http://acm.hdu.edu.cn/showproblem.php?pid=6393 思路:n个点,n条边,也就是基环树..因为只有一个环,我们可以把这个环断开,建一个新的点n+1与之相 ...

  8. IDEA如何刷新pom文件

    被新手问到了“IDEA如何刷新pom文件?”这个问题,想来这是一个不好意思问的常犯的错误吧. 在IDEA中,修改了pom.xml文件,添加了依赖以后,一般会弹出以下这个警告来. 点击[Import C ...

  9. MessageBox函数第一个参数hwnd的作用

    MessageBox 函数用于创建.显示并操作一个消息对话框.该对话框包含由调用程序定义的信息和标题,以及预先定义的图标和按钮. 这个方法的第一个参数hWnd,代表消息框拥有的窗口.这个参数到底有什么 ...

  10. 洛谷P3515 [POI2011]Lightning Conductor(动态规划,决策单调性,单调队列)

    洛谷题目传送门 疯狂%%%几个月前就秒了此题的Tyher巨佬 借着这题总结一下决策单调性优化DP吧.蒟蒻觉得用数形结合的思想能够轻松地理解它. 首先,题目要我们求所有的\(p_i\),那么把式子变一下 ...