Thread: Linked Lists

  1. #1
    Registered User
    Join Date
    Sep 2002
    Posts
    64

    Linked Lists

    If I have an input file of names in this format:

    Bill Clinton:L:George Bush
    George Bush:L:Ronald Reagan

    which would be interpreted as.

    Bush is to the LEFT of Clinton and Reagan is to the left of Bush.

    How would I go about outputting this order with the use of LISTS?

    Ronald Reagan
    George Bush
    Bill Clinton

    ************************************
    I was going to take the approach of reading
    Bill Clinton in to one string
    L into another string
    and George Bush in to another string

    but from there, I don't know how to make use of the list?

  2. #2
    Green Member Cshot's Avatar
    Join Date
    Jun 2002
    Posts
    892
    You can either use singly or doubly linked lists here.

    Allocate 3 objects. Set Clinton's left obj pointer to George. Set George's to Reagan. Likewise if you had a doubly linked list, you'd have to set the appropriate right obj pointers.
    Try not.
    Do or do not.
    There is no try.

    - Master Yoda

  3. #3
    Registered User
    Join Date
    Sep 2002
    Posts
    64
    The file I am reading in doesn't necesarily have those names...I was just using that as an example. Somehow I need the program to recognize the L and go from there.

    But how do I get the string values in to the list in the right order?? I have never used lists.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Linked Lists 101
    By The Brain in forum C++ Programming
    Replies: 5
    Last Post: 07-24-2004, 04:32 PM
  2. Map file formats and linked lists
    By Spitball in forum Game Programming
    Replies: 2
    Last Post: 03-04-2004, 11:32 PM
  3. Linked Lists Integer addition ? HELP Please??
    By green_eel in forum C Programming
    Replies: 3
    Last Post: 03-12-2003, 04:36 PM
  4. need help w/ linked lists
    By MKashlev in forum C++ Programming
    Replies: 11
    Last Post: 08-05-2002, 08:57 PM
  5. doubly linked lists
    By qwertiop in forum C++ Programming
    Replies: 3
    Last Post: 10-03-2001, 06:25 PM