Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- struct link {
- int value;
- link * next;
- };
- int main() {
- link *top;
- link *current, *previous;
- link *lptr;
- int ivalue;
- cout<< "<Input next value, -1 to terminate> \n" <<flush;
- cin>> ivalue;
- top = 0;
- //Build the list
- while (ivalue != -1) {
- lptr = new link;
- lptr->value = ivalue;
- current = top;
- previous = 0;
- //your code here
- lptr = top;
- while ( top ) {
- cout << top->value << ā\nā;
- top = top->next; // top = (*top).next;
- delete lptr;
- lptr = top;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement