Untitled
Never
#include<iostream> #include<string.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; }; //#include<iostream> //#include<string.h> //#include "function.h" //using namespace std; List_stack::List_stack(){ head=new ListNode(0); //tail=head; tail=new ListNode(0); head->nextPtr=tail; tail->prevPtr=head; } List_stack::~List_stack(){ for(ListNode* tmp=head;tmp!=tail;tmp=head){ head=head->nextPtr; delete[] tmp; } } void List_stack::push(const int & n){ ListNode* newNode=new ListNode(n); tail->prevPtr->nextPtr=newNode; newNode->prevPtr=tail->prevPtr; tail->prevPtr=newNode; newNode->nextPtr=tail; } void List_stack::pop(){ if(tail->prevPtr==head)return; tail->prevPtr->prevPtr->nextPtr=tail; ListNode* tmp=tail->prevPtr; tail->prevPtr=tail->prevPtr->prevPtr; delete[] tmp; } void List_stack::print(){ ListNode* cur=tail->prevPtr; if(cur!=head)cout<<cur->data; else return; cur=cur->prevPtr; for(ListNode* tmp=cur;tmp!=head;tmp=cur){ cur=cur->prevPtr; cout<<' '<<tmp->data; } } 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; }
Raw Text
-
Hot Desi Bhabhi Sex Fingering Her Shaved Indian Pussy
1 min ago
-
https://twor.microsoftcrmportals.com/forums/support-forum/6653c3ea-9400-ef11-a73d-6045bd3fd1cb
3 min ago
-
What Is Fitspresso Reviews?
14 min ago
-
Untitled
23 min ago
-
Заехал в гости , малыха оказалась гостеприимной
30 min ago
-
Adult Telegram Channels
38 min ago
-
BLOOM CBD GUMMIES Expert Interview
45 min ago
-
sómiya
50 min ago
-
Untitled
53 min ago
-
Untitled
54 min ago