On Tue, Feb 11, 2003 at 04:05:05PM +0100, Jean-Marc Lasgouttes wrote:
> Andre> Do they need to be sorted at all?
> 
> Yes, probably, so that we can uniquify the list.

This could be solved in twelve lines or so  in any language that has "map"

#include <set>
#include <string>
#include <iostream>

int main()
{
        set<string> seen;
        string word;
        while (cin >> word) 
                if (seen.find(word) == seen.end()) {
                        seen.insert(word);
                        cout << word << ' ';
                }
}

It's probably even shorter in perl.

Andre'

-- 
Those who desire to give up Freedom in order to gain Security,
will not have, nor do they deserve, either one. (T. Jefferson)

Reply via email to