数组排序去重

ref

ref

code

#include<iostream>
#include<algorithm>
using namespace std;
const int N=10;
int a[11];
int main(){
	ios::sync_with_stdio(false);
	for(int i=0;i<N;i++){
		cin>>a[i];
	}
	sort(a,a+N);
	int n=unique(a,a+N)-a;//deduplication
	for(int i=0;i<n;i++){
		cout<<a[i]<<'\n';
	}
	return 0;
}

des

资源限制
时间限制:1.0s 内存限制:512.0MB
问题描述
  输入10个整数组成的序列,要求对其进行升序排序,并去掉重复元素。
输入格式
  10个整数。
输出格式
  多行输出,每行一个元素。
样例输入
2 2 3 3 1 1 5 5 5 5
样例输出
1
2
3
5

posted @ 2022-01-30 15:04  ethon-wang  阅读(60)  评论(0编辑  收藏  举报