Thread: circular linked list question..

  1. #1
    Banned
    Join Date
    Oct 2008
    Posts
    1,535

    circular linked list question..

    i have a circular linked list
    with have a value variable in each node

    and i need to build such a loop so if in a certai node i will have 5 then i will go 5 steps forward
    5 times head=head->next
    till it stops and read the next node value etc..

    i dont know how to do it

    in a for loop i need to change the step every time depending on the value of the node.
    i while loop its the same problem

    ??

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Code:
    for( x = 0; x < y; x++ )
    That'll get you started. Let's see what you've got.


    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    Banned
    Join Date
    Oct 2008
    Posts
    1,535
    lets presume its a function
    head point to some node
    Code:
    node *temp=head;
    while (2>1)
    {
    for(vl=temp->val;vl>0;vl--,temp=temp->next);
    vl=temp->val;
      }
    is it correct?

  4. #4
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Why don't you try it and find out?


    Quzah.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Unknown memory leak with linked lists...
    By RaDeuX in forum C Programming
    Replies: 6
    Last Post: 12-07-2008, 04:09 AM
  2. linked list question
    By mikeman in forum C Programming
    Replies: 1
    Last Post: 11-30-2008, 01:56 PM
  3. How can I traverse a huffman tree
    By carrja99 in forum C++ Programming
    Replies: 3
    Last Post: 04-28-2003, 05:46 PM
  4. linked list question
    By yeahdixon in forum C++ Programming
    Replies: 2
    Last Post: 03-28-2002, 09:16 AM
  5. Linked list with two class types within template.
    By SilasP in forum C++ Programming
    Replies: 3
    Last Post: 02-09-2002, 06:13 AM