STACK.CPP
资源名称:C++100.rar [点击查看]
上传用户:wszmarenbt
上传日期:2013-04-26
资源大小:2552k
文件大小:1k
源码类别:
Windows编程
开发平台:
Visual C++
- //THE PROGRAM IS TO TEST THE CLASS "STACK"
- //FILE STACK.CPP
- #include "STACK.H"
- class STACK : LIST
- {
- public:
- STACK():LIST(){}
- void PUSH(int NUM)
- {
- LIST::FORWARD_ADD(NUM);
- }
- int POP()
- {
- return LIST::GET();
- }
- };
- int main(void)
- {
- int INTNUM;
- STACK TEXT_S;
- clrscr();
- printf(" --- STACK ---");
- printf("n Push 1");
- INTNUM=1;
- TEXT_S.PUSH(INTNUM);
- printf("n Push 4");
- INTNUM=4;
- TEXT_S.PUSH(INTNUM);
- printf("n Push 9");
- INTNUM=9;
- TEXT_S.PUSH(INTNUM);
- INTNUM=TEXT_S.POP();
- printf("n THE FIRST ITEM POPPED FROM THE STACK = %d",INTNUM);
- INTNUM=TEXT_S.POP();
- printf("n THE SECOND ITEM POPPED FROM THE STACK = %d",INTNUM);
- INTNUM=TEXT_S.POP();
- printf("n THE THIRD ITEM POPPED FROM THE STACK = %d",INTNUM);
- getch();
- return 0;
- }