Presentation is loading. Please wait.

Presentation is loading. Please wait.

reverse.cpp #include “stack.h” int main() { Stack stack;

Similar presentations


Presentation on theme: "reverse.cpp #include “stack.h” int main() { Stack stack;"— Presentation transcript:

1 reverse.cpp #include “stack.h” int main() { Stack stack;
int main() { Stack stack; stack.push(1); stack.push(2); stack.push(3); int num; while (!stack.empty()) { cout << stack.top() << endl; stack.pop(); }

2 Pseudocode for Bracket matching
Stack mystack; // declare & initialize stack Loop through all characters in program { if (symbol is an ‘opener’) // (, [, { mystack.push(symbol); if (symbol is a ‘closer’) { // }, ], } if (mystack.empty()) return no_match; else { // check if symbol matches top of stack char stacktop; mystack.top(stacktop); mystack.pop(); if (symbol and stacktop mismatch) return no_match; }


Download ppt "reverse.cpp #include “stack.h” int main() { Stack stack;"

Similar presentations


Ads by Google