-
-
Notifications
You must be signed in to change notification settings - Fork 7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
updated version of stack linked list #2036
base: master
Are you sure you want to change the base?
Conversation
updated version of stack linked list with proper formatting and fixed print statements.
This pull request has been automatically marked as abandoned because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Looks like we might need to use smart pointers instead. |
@@ -1,64 +1,76 @@ | |||
#include <iostream> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#include <iostream> | |
#include <iostream> /// for I/O operations |
int main() | ||
{ | ||
int ch = 0, x = 0; | ||
do { | ||
do | ||
{ | ||
std::cout << "\n0. Exit or Ctrl+C"; | ||
std::cout << "\n1. Push"; | ||
std::cout << "\n2. Pop"; | ||
std::cout << "\n3. Print"; | ||
std::cout << "\nEnter Your Choice: "; | ||
std::cin >> ch; | ||
switch (ch) { | ||
case 0: | ||
break; | ||
case 1: | ||
std::cout << "\nInsert : "; | ||
std::cin >> x; | ||
push(x); | ||
break; | ||
case 2: | ||
pop(); | ||
break; | ||
case 3: | ||
show(); | ||
break; | ||
default: | ||
std::cout << "Invalid option!\n"; | ||
break; | ||
switch (ch) | ||
{ | ||
case 0: | ||
break; | ||
case 1: | ||
std::cout << "\nInsert : "; | ||
std::cin >> x; | ||
push(x); | ||
break; | ||
case 2: | ||
pop(); | ||
break; | ||
case 3: | ||
show(); | ||
break; | ||
default: | ||
std::cout << "Invalid option!\n"; | ||
break; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please use tests
node *t = top_var; | ||
while (t != nullptr) { | ||
while (t != nullptr) | ||
{ | ||
std::cout << t->val << "\n"; | ||
t = t->next; | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/** | |
* @brief Main function | |
* @returns 0 on exit | |
*/ |
updated version of stack linked list with proper formatting and fixed print statements.
Description of Change
Checklist
Notes: