题目描述

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. Node http和express和mysql

    const http = require("http");const express = require("express");const mysql = re ...

  2. loadrunner报错

    Action.c(1516): Error -27727: Step download timeout (120 seconds) has expired when downloading resou ...

  3. Test Scenarios for image upload functionality (also applicable for other file upload functionality)

    1 check for uploaded image path2 check image upload and change functionality3 check image upload fun ...

  4. LODOP、C-LODOP注册号的区别

    LODOP是一款免费的web打印控件,预览打印后无水印,是免费的,直接打印会在纸张下方有个水印“本页由XXX试用版输出”,通常商用打印较多,常用直接打印,这种时候可以购买注册号去水印. LODOP注册 ...

  5. C# 8小特性

    对于C# 8,有吸引了大多数注意力的重大特性,如默认接口方法和可空引用,也有许多小特性被考虑在内.本文将介绍几例可能加入C#未来版本的小特性. 新的赋值运算符:&&=和||= 从第一个 ...

  6. Django-website 程序案例系列-6 ajax案例

    普通ajax案例: views.py def testajax(request): h = request.POST.get('hostname') #拿到ajax传来的值 i = request.P ...

  7. POJ1611-The Suspects-并查集

    记录元素个数的并查集. 利用sz数组保存并查集的大小.每次union时,把小的集合并到大的中去,并更新sz数组. #include <cstdio> #include <algori ...

  8. MyBatis在表名作为参数时遇到的问题

    之前在用MyBatis的时候没用过表名作为参数,最近使用到了. 基于注释使用MyBatis的Dao层代码如下: @Repository public interface Base1102Dao { @ ...

  9. Codeforces Round #411 div 2 D. Minimum number of steps

    D. Minimum number of steps time limit per test 1 second memory limit per test 256 megabytes input st ...

  10. SharePoint 2013 APP 开发示例 (三)使用远程的web资源

    在这个示例里我们将详细介绍 TokenHelper 类, 我们将看到它是怎么简单地从远程web站点访问SharePoint的.我们还将取到它的一些值.这将帮助我们理解连接是怎么被构造的,同时也方便我们 ...