Wednesday, October 8, 2014

3 Operations on Stack Push (o): o Add objects on Stack Pop (): Get the object from Stack isEmpty ()


1 Stack is a container of objects working under the LIFO (Last In First Out), from adding an object on the stack or retrieve an object from the stack are made under the "ON AFTER THE BEFORE ".
3 Operations on Stack Push (o): o Add objects on Stack Pop (): Get the object from Stack isEmpty (): Check for empty or not Top Stack (): Returns the value of the element is Stack started without fire king destroying it from the stack.
void push (Stack & s, Node * p) {if (s.pHead == NULL) {s.pHead = s.pTail = p; Else {p}> pNext = s.pHead; s.pHead = p; Pop}} int (Stack & s) {Node * p; if (s.pHead! = NULL) {p = s.pHead; s.pHead = s.pHead-> pNext; if (NULL == s.pHead) s.pTail = NULL; delete (p); return 1;
Return 0}; PrintStack} fire king void (Stack s) {Node * p; p = s.pHead; while (p! = NULL) {printf ("% 3d", p-> info); p = p-> pNext; _tmain}} Int (int argc, argv _TCHAR * []) {Stack fire king s; Node * p; CreateStack (s); for (int i = 1; i <= 5; i ++) {p = CreateNode (i); Push (s, p); } Printf ("Stack"); PrintStack (s);
Letter to Parents School, Luong The Vinh
Blog at WordPress.com. | The Zoren Theme.
% D bloggers like this:

No comments:

Post a Comment