driver.cpp
来自「经典vc教程的例子程序」· C++ 代码 · 共 52 行
CPP
52 行
// Stack test program
#include <iostream.h>
#include "stack.h"
int main()
{
Stack<int> intStack;
cout << "Pushing integers on intStack" << endl;
for ( int i = 0; i < 5; i++ ) {
intStack.push( i ); // put items in the stack
cout << i << ' ';
}
cout << endl;
intStack.print(); // output the stack contents
cout << endl << "Popping integers from intStack" << endl;
while ( !intStack.isEmpty() )
cout << intStack.pop() << ' '; // remove items
cout << endl;
intStack.print(); // output the stack contents
Stack<char> charStack;
cout << endl << endl
<< "Pushing characters on charStack" << endl;
for ( char c = 'A'; c < 'E'; c++ ) {
charStack.push( c ); // put items in the stack
cout << c << ' ';
}
cout << endl;
charStack.print(); // output the stack contents
cout << endl << "Popping characters from charStack" << endl;
while ( !charStack.isEmpty() )
cout << charStack.pop() << ' '; // remove items
cout << endl;
charStack.print(); // output the stack contents
return 0;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?