HELP dont understand why it not working

in this program we have to make a kill function that kill to the right using a link list and a skip number. so if i have a b c d and skip one.
a kills c
d kills b
a kills a
d wins

i using this loop
while(size!=1)
{
pos=0;
kill (head,pos,skipNum,success,size--,killvic); killvic.killer=retrieve(head,1+findNodeKiller(head,pos,killvic)),success);
}

And this function___________________________________________________
static void kill (nodePtr& head,int pos,int skipNum,bool& success,int size,tracker &killvic)
{
findNodeVictim(head,pos,skipNum,killvic,success);
cout<<killvic.killer<<" kills "<<killvic.victim;
remove(head,(1+findNodeKiller(head,pos,killvic)+skipNum),success);
printLL(head,success);
}
____________________________________________________
static int findNodeKiller (nodePtr& head,int pos, tracker &killvic)
{
bool success;
while (retrieve(head,pos,success)!=killvic.killer)
{
if (retrieve(head,pos,success)==killvic.killer)
return (pos);
pos++;
}
}
____________________________________________________________________
static void findNodeVictim(nodePtr& head,int pos,int skipNum, tracker &killvic,bool& success)
{
if(success==1)
{
int nodeloc=1+findNodeKiller(head,pos,killvic)+skipNum;
killvic.victim=retrieve(head,nodeloc,success);
}
}
when i use this program a b c d skips 0

a kills b
c kills a
c kills c
d wins
closed account (236Rko23)
if you could add some comments explaining what each function does, because folowing 3 functions one inside another and on top of that there are missing variables and functions it's kind of a pain trying to understand it.
and when inserting code please use [ code] [ /code] to separate it from the rest of the text, plus it highlights the c++ sintax.
Last edited on
Topic archived. No new replies allowed.