当前位置:网站首页>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;
}
边栏推荐
- 如何通过API接口从淘宝(或天猫店)复制宝贝到拼多多接口代码对接教程
- Variable string
- KunlunBase 1.0 is released!
- nodejs installation and environment configuration
- SAP SD模块前台操作
- 安全至上:落地DevSecOps最佳实践你不得不知道的工具
- Analysis of usage scenarios of mutex, read-write lock, spin lock, and atomic operation instructions xaddl and cmpxchg
- 实例039:有序列表插入元素
- 持续投入商品研发,叮咚买菜赢在了供应链投入上
- [store mall project 01] environment preparation and testing
猜你喜欢
通用的测试用例编写大全(登录测试/web测试等)

ASP.NET 获取数据库的数据并写入到excel表格中

MySQL回表指的是什么

5.scrapy中间件&分布式爬虫

Continuing to invest in product research and development, Dingdong Maicai wins in supply chain investment

实例041:类的方法与变量

The idea of the diagram

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

什么是SVN(Subversion)?

typescript51 - basic use of generics
随机推荐
Parquet encoding
Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.
贪吃蛇游戏Bug解析及功能扩展
JS 保姆级贴心,从零教你手写实现一个防抖debounce方法
typescript51 - basic use of generics
MySQL回表指的是什么
boot issue
Use nodejs switch version (no need to uninstall and reinstall)
网页三维虚拟展厅为接入元宇宙平台做基础
KunlunBase 1.0 is released!
LeetCode third topic (the Longest Substring Without Repeating Characters) trilogy # 3: two optimization
esp32发布机器人电池电压到ros2(micro-ros+CoCube)
Intranet penetration - application
Deng Qinglin, Alibaba Cloud Technical Expert: Best Practices for Disaster Recovery across Availability Zones and Multiple Lives in Different Locations on the Cloud
GNSS[0]- Topic
VR panorama shooting online exhibition hall, 3D panorama brings you an immersive experience
Demand analysis of MES management system in electronic assembly industry
GNSS文章汇总
Continuing to invest in product research and development, Dingdong Maicai wins in supply chain investment
实例037:排序