Thread: compare duplicate

  1. #1
    accord
    Guest

    Smile compare duplicate

    Code:
    column 1            column 2
     
    test                   happy
    check                program
    run                    place
    bat                    bat
    heart                 bat
    if you have the data above and you wanted to check and see if a string in column 2 appears in column 1. How would
    I go about doing this without checking for the same string twice?

    As you see column 2 has bat listed twice, how do you perform this check only once without checking for bat again?

  2. #2
    accord
    Guest

    Smile

    so in my program just loop through and search for the duplicates and remove them? could you give an example thanks.

  3. #3
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,817
    An easy way to not have to consider duplicates would be to store your two groups of data into a set container. If you create a couple set<string> containers and try to insert the same value into the same container then that operation will fail. In the end of all your insert operations, your two set objects will only have unique entries.
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

  4. #4
    accord
    Guest

    Smile

    thanks guys

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. compare strings not working
    By gtriarhos in forum C Programming
    Replies: 7
    Last Post: 09-29-2005, 12:51 PM
  2. Help Writing My Own String Compare
    By djwicks in forum C Programming
    Replies: 4
    Last Post: 04-07-2005, 09:44 PM
  3. String Compare Using Dynamic Arrays
    By djwicks in forum C Programming
    Replies: 4
    Last Post: 03-31-2005, 08:01 PM
  4. How to duplicate a tree?
    By franziss in forum C Programming
    Replies: 2
    Last Post: 01-16-2005, 12:23 AM
  5. duplicate detection algorithm
    By Gustaff in forum C Programming
    Replies: 4
    Last Post: 01-28-2003, 12:26 PM