cpp 10.10
来源:互联网 发布:罗德曼生涯数据 编辑:程序博客网 时间:2024/05/29 03:14
stack.h
#pragma oncetypedef unsigned long Item;class Stack{private:enum { MAX = 10 };Item items[MAX];int top;public:Stack();bool isempty() const;bool isfull() const;bool push(const Item & item);bool pop(Item & item);};
stack.cpp
#include "stack.h"Stack::Stack(){top = 0;}bool Stack::isempty() const{return top == 0;}bool Stack::isfull() const{return top == MAX;}bool Stack::push(const Item & item){if (top < MAX){items[top++] = item;return true;}elsereturn false;}bool Stack::pop(Item & item){if (top > 0){item = items[--top];return true;}elsereturn false;}
stacker.cpp
#include<iostream>#include<cctype>#include"stack.h"int main(){using namespace std;Stack st;char ch;unsigned long po;cout << "Please enter A to add purchase order,\n"<< "P to process a PO, or Q to quit.\n";while (cin >> ch && toupper(ch) != 'Q'){while (cin.get() != '\n')continue;if (!isalpha(ch)){cout << '\a';continue;}switch (ch){ case 'A': case 'a': cout << "Enter a PO number to add: "; cin >> po; if (st.isfull()) cout << "stack already full\n"; else st.push(po); break;case 'p':case 'P': if (st.isempty()) cout << "stack already empty\n"; else { st.pop(po); cout << "PO #" << po << " popped\n"; } break;}cout << "Please enter A to add a purchase order,\n"<< "P to process a PO, or Q to quit.\n";}cout << "Bye\n";system("pause");return 0;}
0 0
- cpp 10.10
- cpp
- CPP
- CPP
- cpp
- cpp
- CPP
- CPP
- ClientSockThread.cpp&&ClientUrlThread.cpp
- cpp调用其他cpp
- ex34a.cpp&&ex34aDoc.cpp&&ex34aView.cpp
- MainFrm.cpp&&ServerThread.cpp&&SheetConfig.cpp
- CPP thread
- cpp->html
- CFaderWnd.cpp
- PasswordReminder.cpp
- object.cpp
- CmdTarget.cpp
- c# override
- GPUImage滤镜
- TypeError: the JSON object must be str, not 'bytes'
- Android Studio出现Error:No service of type Factory available in ProjectScopeServices.
- 每天一个linux命令(21):find命令之xargs
- cpp 10.10
- 保存或打开文件
- android 以追加形式写文件并把文件保存到SD卡中
- VS2012+mysql
- Java学习博客和文章存档
- BZOJ 1588: [HNOI2002]营业额统计 (Treap/链表)
- 桶排序
- sqlite3.lib编译生成
- 利用UltraISO制作U盘启动盘