📄 7-3-1.cpp
字号:
#include <iostream.h>
#define STACKSIZE 10
class Stack {
private:
long buffer[STACKSIZE];
long *sp;
public:
Stack() { sp = buffer; }
~Stack() { };
void push(long data) {
if(sp >= buffer+STACKSIZE)
cerr << "Stack overflow !" << endl;
else {
*sp ++ = data;
cout << data << " is pushed !" << endl;
}
}
long pop() {
if(sp <= buffer) {
cerr << "Stack is Empty!" << endl;
return 0;
}
else return *--sp;
}
};
main()
{ Stack a;
a.push(351); a.push(7075461); a.push(3225);
cout << endl;
cout << a.pop() << " is poped !" << endl;
cout << a.pop() << " is poped !" << endl;
cout << a.pop() << " is poped !" << endl;
cout << a.pop() << " is poped !" << endl;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -