当前位置:网站首页>Simple sorting (summer vacation daily question 14)
Simple sorting (summer vacation daily question 14)
2022-08-04 01:40: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;
}
边栏推荐
- lombok注解@RequiredArgsConstructor的使用
- Deng Qinglin, Alibaba Cloud Technical Expert: Best Practices for Disaster Recovery across Availability Zones and Multiple Lives in Different Locations on the Cloud
- Promise 解决阻塞式同步,将异步变为同步
- Continuing to invest in product research and development, Dingdong Maicai wins in supply chain investment
- LDO investigation
- Flink jdbc connector 源码改造sink之 clickhouse多节点轮询写与性能分析
- 一篇文章看懂JS闭包,从执行上下文角度解析有趣的闭包
- typescript56 - generic interface
- 一个项目的整体测试流程有哪几个阶段?测试方法有哪些?
- priority_queue元素为指针时,重载运算符失效
猜你喜欢

计算首屏时间

【日志框架】

redis中常见的问题(缓存穿透,缓存雪崩,缓存击穿,redis淘汰策略)

静态/动态代理模式

GraphQL背后处理及执行过程是什么

Android interview questions and answer analysis of major factories in the first half of 2022 (continuously updated...)

阿里云技术专家邓青琳:云上跨可用区容灾和异地多活最佳实践

114. How to find the cause of Fiori Launchpad routing error by single-step debugging

idea中diagram使用

什么是SVN(Subversion)?
随机推荐
Deng Qinglin, Alibaba Cloud Technical Expert: Best Practices for Disaster Recovery across Availability Zones and Multiple Lives in Different Locations on the Cloud
Sky map coordinate system to Gaode coordinate system WGS84 to GCJ02
initramfs详解----添加硬盘驱动并访问磁盘
网络带宽监控,带宽监控工具哪个好
字符串的排列
实例038:矩阵对角线之和
《Greenplum构建实时数据仓库实践》简介
【虚拟化生态平台】虚拟化平台esxi挂载USB硬盘
【store商城项目01】环境准备以及测试
持续投入商品研发,叮咚买菜赢在了供应链投入上
Promise solves blocking synchronization and turns asynchronous into synchronous
无代码7月热讯 | 微软首推数字联络中心平台;全球黑客马拉松...
【QT小记】QT中信号和槽的基本使用
哎,又跟HR在小群吵了一架!
typescript56 - generic interface
计算首屏时间
How to copy baby from Taobao (or Tmall store) through API interface to Pinduoduo interface code docking tutorial
通用的测试用例编写大全(登录测试/web测试等)
C 学生管理系统_添加学生
工程制图名词解释-重点知识