int main() { IntStack s; s.push(1); s.push(2); s.push(3); s.clear(); s.top(); s.pop(); return 0; }
int main() { IntStack intStack; intStack.push(1); intStack.push(2); intStack.push(3); while (!intStack.empty()) { int t = intStack.top(); intStack.pop(); printf("%d\n", t); } intStack.push(4); intStack.push(5); while (!intStack.empty()) { int t = intStack.top(); intStack.pop(); printf("%d\n", t); } return 0; }
int main() { IntStack stack; while(true) { string cmd; cin >> cmd; if(cmd == "push") { int elem; cin >> elem; stack.push(elem); } if(cmd == "pop") { stack.pop(); } if(cmd == "top") { cout << stack.top() << " is at the top" << endl; } cout << stack << endl; }