Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- tepmlate<typename type>
- struct stack {
- type data[100];
- int sz;
- stack() {
- sz = 0;
- }
- void push(type x) {
- // code here!
- }
- void pop() {
- // code here!
- }
- int size() {
- // code here!
- }
- bool empty() {
- // code here!
- }
- type top() {
- // code here!
- }
- };
- int main() {
- stack<int> s;
- s.push(10);
- s.push(20);
- s.push(30);
- cout << s.size() << endl;
- cout << s.top() << endl;
- s.push(40);
- cout << s.top() << endl;
- s.pop();
- s.pop();
- cout << s.top() << endl;
- while(!s.empty()) {
- cout << s.top() << endl;
- s.pop();
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement