Untitled
Never
#include <string.h> #include <iostream> #include "function.h" using namespace std; class ListNode { friend class List_stack; //make List_stack a friend public: ListNode( const int &info ) //constructor : data( info ), nextPtr( NULL ), prevPtr( NULL ) { } //end ListNode constructor private: int data; //data ListNode *nextPtr; // next node in list ListNode *prevPtr; }; //end class ListNode class List_stack { public: List_stack(); ~List_stack(); void push(const int &); void pop(); void print(); private: ListNode *head; ListNode *tail; }; List_stack::List_stack() { head = tail = nullptr; } List_stack::~List_stack() { ListNode* p = head; ListNode* q = p; while (p) { p = p->nextPtr; delete q; q = p; } } void List_stack::push(const int& n) { if (head == nullptr) { head = tail = new ListNode(n); } else { tail->nextPtr = new ListNode(n); tail->nextPtr->prevPtr = tail; tail = tail->nextPtr; } } void List_stack::pop() { if(tail == nullptr) return; if(tail->prevPtr == nullptr) { delete tail; head = tail = nullptr; } else { tail = tail->prevPtr; delete tail->nextPtr; tail->nextPtr = nullptr; } } void List_stack::print() { if (tail == nullptr) return; ListNode* p = tail; cout << p->data; p = p->prevPtr; while (p != nullptr) { cout << " " << p->data; p = p->prevPtr; } } int main(){ List_stack L_stack; char command[10]; int n; while(cin>>command){ if(strcmp(command,"pop")==0){ L_stack.pop(); }else if(strcmp(command,"push")==0){ cin >> n; L_stack.push(n); }else if(strcmp(command, "print") == 0){ L_stack.print(); cout << endl; } } return 0; } /* push 2 push 120 pop print pop print push 22 push 35 print */
Raw Text
-
Happy birthday! I'll let you fuck me, but don't cum inside! - AdaKham
23 min ago
-
My sexy stepsister invite me for great fuck
53 min ago
-
i n c e s t
1 hour ago
-
PTHC
1 hour ago
-
CPLOLI
1 hour ago
-
C..P V.I.D..E.O.S
1 hour ago
-
y0ung parad1se
1 hour ago
-
ukrainian ped0mom
1 hour ago
-
asdfgewrtyudfghjkl
1 hour ago
-
Mixed 720GB CeePee
1 hour ago