Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

#ActualMrChrisnis

Posted 19 October 2012 - 08:01 AM

Okay, I've tried implementing my own insertion sorting after writing it out, and it is still confusing me. This causes the program to pretty much break after one Beast has been inserted into the list. It doesn't break out or crash or anything like that, it just stops outputting the command line requests that it is supposed to and stop allowing the user to enter in any more inputs.

If you guys could look through it and give me some hints on how I can fix this it would be great Posted Image

Thanks,
Chris

P.S - I have tried! Posted Image

EDIT: My code is displaying in this post as though it is on one long line. I am not sure how to fix this or if it is showing like this for other people so I am sorry if it is

#3MrChrisnis

Posted 14 October 2012 - 01:49 PM

Okay, I've tried implementing my own insertion sorting after writing it out, and it is still confusing me. This causes the program to pretty much break after one Beast has been inserted into the list. It doesn't break out or crash or anything like that, it just stops outputting the command line requests that it is supposed to and stop allowing the user to enter in any more inputs.

If you guys could look through it and give me some hints on how I can fix this it would be great Posted Image

Thanks,
Chris

P.S - I have tried! Posted Image

EDIT: My code is displaying in this post as though it is on one long line. I am not sure how to fix this or if it is showing like this for other people so I am sorry if it is =S

[source lang="cpp"]void SimpleLinkedList::add_numerical(Beast *b) { if(head == NULL) { head = b; return; } Beast *previous = head; Beast *next = previous->get_next(); while(next != NULL) { if(head->get_HP() < b->get_HP()) { next = head; head = b; b->set_next(next); } if(next->get_HP() <= b->get_HP()) { previous->set_next(b); next = next->get_next(); } if(next->get_HP() > b->get_HP()) { next = next->get_next(); } }}[/source]

#2MrChrisnis

Posted 14 October 2012 - 01:48 PM

Okay, I've tried implementing my own insertion sorting after writing it out, and it is still confusing me. This causes the program to pretty much break after one Beast has been inserted into the list. It doesn't break out or crash or anything like that, it just stops outputting the command line requests that it is supposed to and stop allowing the user to enter in any more inputs.

If you guys could look through it and give me some hints on how I can fix this it would be great Posted Image

Thanks,
Chris

P.S - I have tried! Posted Image

[source lang="cpp"]void SimpleLinkedList::add_numerical(Beast *b) { if(head == NULL) { head = b; return; } Beast *previous = head; Beast *next = previous->get_next(); while(next != NULL) { if(head->get_HP() < b->get_HP()) { next = head; head = b; b->set_next(next); } if(next->get_HP() <= b->get_HP()) { previous->set_next(b); next = next->get_next(); } if(next->get_HP() > b->get_HP()) { next = next->get_next(); } }}[/source]

#1MrChrisnis

Posted 14 October 2012 - 01:47 PM

Okay, I've tried implementing my own insertion sorting after writing it out, and it is still confusing me. This causes the program to pretty much break after one Beast has been inserted into the list. It doesn't break out or crash or anything like that, it just stops outputting the command line requests that it is supposed to and stop allowing the user to enter in any more inputs.

If you guys could look through it and give me some hints on how I can fix this it would be great :)

Thanks,
Chris

P.S - I have tried! :(

[source lang="cpp"]void SimpleLinkedList::add_numerical(Beast *b) { if(head == NULL) { head = b; return; } Beast *previous = head; Beast *next = previous->get_next(); while(next != NULL) { if(head->get_HP() < b->get_HP()) { next = head; head = b; b->set_next(next); } if(next->get_HP() <= b->get_HP()) { previous->set_next(b); next = next->get_next(); } if(next->get_HP() > b->get_HP()) { next = next->get_next(); } }}[/source]

PARTNERS