+ 2

There is an array which consists of n integers . we have to delete items which are equal . First equal item is declared .

for example : int Parray [6] = {1 , 2 , 1 , 1, 5 , 6}; result is { 1 , 2 , 5 , 6 } ( I'm sorry if it's complicated , my English isn't so good )

18th Mar 2018, 10:22 AM
Jakhongir
Jakhongir - avatar
1 Odpowiedź
+ 3
void unify(int arr[], int& size) { set<int> s; for(int i=0;i<size;i++) s.insert(arr[i]); size=s.size(); copy(arr,arr+size,s.begin()); } That removes any duplicates inside your array.
18th Mar 2018, 10:59 AM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar