当前位置:网站首页>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;
}
边栏推荐
- 无代码7月热讯 | 微软首推数字联络中心平台;全球黑客马拉松...
- typescript58 - generic classes
- How to copy baby from Taobao (or Tmall store) through API interface to Pinduoduo interface code docking tutorial
- Vant3 - click on the corresponding name name to jump to the next page corresponding to the location of the name of the TAB bar
- MySQL回表指的是什么
- this巩固训练,从两道执行题加深理解闭包与箭头函数中的this
- ThreadLocal
- nodejs installation and environment configuration
- Continuing to invest in product research and development, Dingdong Maicai wins in supply chain investment
- 一个注解替换synchronized关键字:分布式场景下实现方法加锁
猜你喜欢
nodejs+express实现数据库mysql的访问,并展示数据到页面上
GraphQL背后处理及执行过程是什么
2022 China Computing Power Conference released the excellent results of "Innovation Pioneer"
pygame 中的transform模块
Slipper - virtual point, shortest path
nodejs+npm的安装与配置
jmeter distributed stress test
initramfs详解----添加硬盘驱动并访问磁盘
LeetCode第三题(Longest Substring Without Repeating Characters)三部曲之三:两次优化
工程制图复习题
随机推荐
Summary of GNSS Articles
谁说程序员不懂浪漫,表白代码来啦~
无代码7月热讯 | 微软首推数字联络中心平台;全球黑客马拉松...
The 600MHz band is here, will it be the new golden band?
Intranet penetration - application
typescript51 - basic use of generics
贴纸拼词 —— 记忆化搜索 / 状压DP
工程制图平面投影练习
静态/动态代理模式
内网穿透-应用
Sky map coordinate system to Gaode coordinate system WGS84 to GCJ02
FeatureNotFound( bs4.FeatureNotFound: Couldn't find a tree builder with the features you requested:
Sticker Spelling - Memory Search / Shape Pressure DP
计算首屏时间
esp32发布机器人电池电压到ros2(micro-ros+CoCube)
How to copy baby from Taobao (or Tmall store) through API interface to Pinduoduo interface code docking tutorial
Continuing to invest in product research and development, Dingdong Maicai wins in supply chain investment
typescript48 - type compatibility between functions
vxe-table 从页面批量删除数据 (不动数据库里的数据)
Apache DolphinScheduler新一代分布式工作流任务调度平台实战-中