?? c19_02.cpp
字號:
// 測試堆棧類模板 Stack
#include "stack.cpp"
int main()
{
cout<<"---- 整數(shù)堆棧 ----\n";
Stack <int> x(5); //定義一個可以放5個整型元素的堆棧
x . push( 1 );
x . push( 2 );
cout << x.pop() << endl;
x . push( 3 );
x . push( 4 );
cout << x.pop() << endl;
cout << x.pop() << endl;
cout << x.pop() << endl<<endl;
cout<<"---- 浮點數(shù)堆棧 ----\n";
Stack <float> y(6); //定義一個可以放6個浮點型元素的堆棧
y . push( 2.1f );
y . push( 3.4f );
cout << y.pop() << endl;
y . push( 5.2f);
y . push( 2.5f );
cout << y.pop() << endl;
cout << y.pop() << endl;
cout << y.pop() << endl<<endl;
cout<<"---- 字符串堆棧 ----\n";
Stack <char *> z(2); //定義一個可以放2個字符元素的堆棧
z.push("programing");
z.push("template");
cout << z.pop() << endl;
cout << z.pop() << endl<< endl;
return 0;
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -