[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: help with C algorythm (find unique value in an array) could you please make changes



On 1/22/07, Mike Polyakov <mike.polyakov@gmail.com> wrote:
For speed of writing, here's the whole thing in C++ using STL:

#include <vector>
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;

int main()
{
  srand(time(NULL));
  vector<int> array;                        // original array
  vector<int> unique;                     // each unique element from

Why not just use a std::set<int> here?  Repeated inserts of the same
value will be ignored.

--
Michael A. Marsh
http://www.umiacs.umd.edu/~mmarsh
http://mamarsh.blogspot.com



Reply to: