?? 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 + -