#include <iostream>
#include <string>
using namespace std;
int reduce(long arr[], int n) {
sort(arr, arr + n);
auto str = unique(arr, arr + n);
return str - arr;
}
int main() {
long arr[10] = { 15, 8, 5, 6, 11, 11, 6, 6, 198, 50 };
int newsize = reduce(arr, 10);
std::ostream_iterator<long, char> out(std::cout, " ");
std::copy(arr, arr + newsize, out);
std::cout << std::endl;
std::cout << "There are " << newsize << " numbers.";
return 0;
}
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】凌霞软件回馈社区,携手博客园推出1Panel与Halo联合会员
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步