How do Recursive menu in laravel 5?

C++ CODE I'M CODING A PRIORITY QUEUE CODE WITH A MENU, TO ADD, DELETE AND LIST. USING RECURSIVE SUB PROGRAMS?

  • HERES WHAT I HAVE.. Could anybody point me in the right direction to finish?? # <stdio.h> /* LIST DEFINED*/ typedef struct listnode{ int datum; struct listnode * next; }*list; /* Random Number Generator*/ int randu(){ static int seed=17; seed= (25173*seed + 13849)% 65536; return seed; } /* Incomplete Recursive Sub-Programs*/ add(){ } listnode(){ } deletenode(){ } /* Main Program with menu*/ main(){ char choice[2]; int quit=0; while (quit !=1) { printf("a- add what number?\n"); printf("d- delete what number?\n"); printf("l-to list\n"); printf("q-quit\n"); scanf("%s", choice); switch( choice[0]) { case 'a': case 'A': add(); break; case'l': case'L': listnode(); break; case'd': case'D': deletenode(); break; case'q': case'Q': quit() break; } } }

  • Answer:

    Here's a few big hints. You need a class or struct that stores your item. The item will contain a pointer to the next item in the list. This is called a linked list. Also those things you called sub-programs are called functions, and in other languages they may be called subroutines, but I've never heard them called subprograms. After writing this I see you already created your struct for the linked list, that's the right way to do it, now you just need to flesh out add and delte like so. Add //Create a new "node" which you call listnode //Assign it to the next variable on the last node in the list (the end of the linked list) Delete //asuming you can only delete the last item! //set the last items parent node's next variable to null. Since this is a singly linked list (it doesn't have a previous variable in the struct that allows you to back up the list, you can only go down, by accessing each items next variable), it will be a teeny bit tricky, you have to stop when you get to the node that's next variable is equal to the lastNode which is a variable I see you don't use, but would be helpful to maintain, that and firstNode. I hope this helps, I'm not trying to do your work for you, but point you in the right direction.

shannon w at Yahoo! Answers Visit the source

Was this solution helpful to you?

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.