当前位置:网站首页>简单排序(暑假每日一题 14)
简单排序(暑假每日一题 14)
2022-08-04 01:37:00 【sweetheart7-7】
给定一个包含 n n n 个整数的数组,请你删除数组中的重复元素并将数组从小到大排序后输出。
输入格式
第一行包含一个整数 n n n。
第二行包含 n n n 个不超过 1000 1000 1000 的正整数。
输出格式
输出去重和排序完毕后的数组。
数据范围
1 ≤ n ≤ 1000 1≤n≤1000 1≤n≤1000
输入样例:
6
8 8 7 3 7 7
输出样例:
3 7 8
#include<iostream>
#include<algorithm>
using namespace std;
const int N = 1010;
int n;
int a[N];
int main(){
cin >> n;
for(int i = 0; i < n; i++)
cin >> a[i];
sort(a, a + n);
n = unique(a, a + n) - a;
for(int i = 0; i < n; i++)
cout << a[i] << ' ';
return 0;
}
边栏推荐
- 工程制图名词解释-重点知识
- Continuing to invest in product research and development, Dingdong Maicai wins in supply chain investment
- Sky map coordinate system to Gaode coordinate system WGS84 to GCJ02
- C # WPF equipment monitoring software (classic) - the next
- JS 保姆级贴心,从零教你手写实现一个防抖debounce方法
- 哎,又跟HR在小群吵了一架!
- How to find the cause of Fiori Launchpad routing errors by single-step debugging
- How to copy baby from Taobao (or Tmall store) through API interface to Pinduoduo interface code docking tutorial
- 在Activity中获取另一个XML文件的控件
- DDTL:远距离的域迁移学习
猜你喜欢

【OpenCV】-重映射

Flask框架初学-05-命令管理Manager及数据库的使用

The idea of the diagram

Vant3 - click on the corresponding name name to jump to the next page corresponding to the location of the name of the TAB bar

静态文件快速建站

ASP.NET 获取数据库的数据并写入到excel表格中
观察者模式

JS 从零教你手写节流throttle

Apache DolphinScheduler新一代分布式工作流任务调度平台实战-中

2022年上半年各大厂Android面试题整理及答案解析(持续更新中......)
随机推荐
typescript52 - simplify generic function calls
GNSS【0】- 专题
114. How to find the cause of Fiori Launchpad routing error by single-step debugging
ASP.NET 获取数据库的数据并写入到excel表格中
What warehouse management problems can WMS warehouse management system solve in the electronics industry?
LDO investigation
Promise 解决阻塞式同步,将异步变为同步
typescript58 - generic classes
Continuing to invest in product research and development, Dingdong Maicai wins in supply chain investment
thinkphp 常用技巧
Flask Framework Beginner-06-Add, Delete, Modify and Check the Database
idea中diagram使用
多线程 之 JUC 学习篇章一 创建多线程的步骤
多渠道打包
typescript51 - basic use of generics
ThreadLocal
持续投入商品研发,叮咚买菜赢在了供应链投入上
C语言:学生管理系统(链表版)
Sticker Spelling - Memory Search / Shape Pressure DP
5. Scrapy middleware & distributed crawler