#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; }标签:std,arr,函数,int,reduce,数组 From: https://www.cnblogs.com/smartlearn/p/18025865