#include<iostream> #include<algorithm> using namespace std; int main(){ int arr[] = {0,1,2,2,3,0,0,3,4,4,5,5,5,6,6,6}; //相邻去重 需要配合sort() int *r = unique(arr,arr+14); //unique() 的返回值是去重后的尾地址 for (int i = 0; i < r-arr; i++) cout << arr[i] << " "; return 0; }
15 total views, 1 views today