当前位置:网站首页>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;
}
边栏推荐
- The 600MHz band is here, will it be the new golden band?
- FeatureNotFound( bs4.FeatureNotFound: Couldn't find a tree builder with the features you requested:
- typescript57 - Array generic interface
- Download install and create/run project for HBuilderX
- 【OpenCV】-重映射
- HBuilderX的下载安装和创建/运行项目
- JS 从零教你手写节流throttle
- 持续投入商品研发,叮咚买菜赢在了供应链投入上
- OpenCV如何实现Sobel边缘检测
- nodejs切换版本使用(不需要卸载重装)
猜你喜欢
谁说程序员不懂浪漫,表白代码来啦~
5. Scrapy middleware & distributed crawler
Web APIs BOM- 操作浏览器:swiper 插件
nodejs installation and environment configuration
OpenCV如何实现Sobel边缘检测
lombok注解@RequiredArgsConstructor的使用
initramfs详解----添加硬盘驱动并访问磁盘
nodejs+express realizes the access to the database mysql and displays the data on the page
typescript57 - Array generic interface
GraphQL背后处理及执行过程是什么
随机推荐
Continuing to invest in product research and development, Dingdong Maicai wins in supply chain investment
Demand analysis of MES management system in electronic assembly industry
Intranet penetration - application
MySQL回表指的是什么
this巩固训练,从两道执行题加深理解闭包与箭头函数中的this
Electronics manufacturing enterprise deployment WMS what are the benefits of warehouse management system
boot issue
LeetCode third topic (the Longest Substring Without Repeating Characters) trilogy # 3: two optimization
静态/动态代理模式
哎,又跟HR在小群吵了一架!
贪吃蛇游戏Bug解析及功能扩展
appium软件自动化测试框架
The 600MHz band is here, will it be the new golden band?
.NET Static Code Weaving - Rougamo Release 1.1.0
数组_滑动窗口 | leecode刷题笔记
Variable string
网页三维虚拟展厅为接入元宇宙平台做基础
Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.
无代码7月热讯 | 微软首推数字联络中心平台;全球黑客马拉松...
【日志框架】