#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;
}

posted on 2024-02-21 17:47  wshidaboss  阅读(4)  评论(0编辑  收藏  举报