[White] road to learning C ++ C ++ classic code

Record number of rewarding code.

 

1, vector elements to weight

sort(v.begin(), v.end());
v.erase(unique(v.begin(), v.end()), v.end());

sort () function to sort vector;

unique () function allows repeating elements on the final return iterator start of repetitive elements;

erase () function is turned off element according to erase.

Guess you like

Origin www.cnblogs.com/ACStrive/p/11586459.html