This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
#include<bits/stdc++.h>
using namespace std;
//数组长度
const int n=10;
/*
功能:打印一维数组
作者:黄海
时间:2019-10-29
*/
void printArray(int a[n]) {
for (int i = 0; i < n; i++) {
cout << a[i] << " ";
}
cout<<endl;
int main() {
// 测试数据
int a[n] = { 0, 7, 7, 6, 1, 1, 5, 5, 8, 9 };
int length= (sizeof(a) / sizeof(a[0]));
//去重前打印输出
printArray(a);
//先排序再去重(由小到大:less,由大到小:greater)
sort(a, a + n, less<int>() );
//开始去重
int n = unique(a, a + length) - a;
//输出去重后的数组
for (int i = 0; i < n; i++)
{
return 0;