当前位置:网站首页>简单排序(暑假每日一题 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;
}
边栏推荐
- Analysis of usage scenarios of mutex, read-write lock, spin lock, and atomic operation instructions xaddl and cmpxchg
- 有没有jdbc 链接优炫数据库文档及示例?
- this巩固训练,从两道执行题加深理解闭包与箭头函数中的this
- C 学生管理系统_分析
- 2022 中国算力大会发布“创新先锋”优秀成果
- 简单的线性表的顺序表示实现,以及线性表的链式表示和实现、带头节点的单向链表,C语言简单实现一些基本功能
- 实例035:设置输出颜色
- LeetCode第三题(Longest Substring Without Repeating Characters)三部曲之三:两次优化
- Is there any jdbc link to Youxuan database documentation and examples?
- 持续投入商品研发,叮咚买菜赢在了供应链投入上
猜你喜欢

OpenCV如何实现Sobel边缘检测

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

Array_Sliding window | leecode brushing notes

实例040:逆序列表

Electronics manufacturing enterprise deployment WMS what are the benefits of warehouse management system

2022年上半年各大厂Android面试题整理及答案解析(持续更新中......)

lombok注解@RequiredArgsConstructor的使用

【日志框架】

静态/动态代理模式

Web APIs BOM- 操作浏览器:swiper 插件
随机推荐
工程制图平面投影练习
C # WPF equipment monitoring software (classic) - the next
实例039:有序列表插入元素
Quickly build a website with static files
一篇文章看懂JS闭包,从执行上下文角度解析有趣的闭包
this巩固训练,从两道执行题加深理解闭包与箭头函数中的this
initramfs详解----添加硬盘驱动并访问磁盘
redis中常见的问题(缓存穿透,缓存雪崩,缓存击穿,redis淘汰策略)
typescript58 - generic classes
nodejs+express实现数据库mysql的访问,并展示数据到页面上
C 学生管理系统 显示链表信息、删除链表
Slipper - virtual point, shortest path
字符串的排列
pygame 中的transform模块
实例038:矩阵对角线之和
Apache DolphinScheduler新一代分布式工作流任务调度平台实战-中
工程制图复习题(带答案)
循环绕过问题
Promise 解决阻塞式同步,将异步变为同步
Continuing to invest in product research and development, Dingdong Maicai wins in supply chain investment