?? 10_5.cpp
字號(hào):
//10_5.cpp
#include <iostream>
#include <queue> //聲明Queue容器適配器頭文件
using namespace std;
template< class T >
void popElements( T &s );
void main()
{
queue< int > intDequeQueue; // 默認(rèn)情況下以Queue容器作為基礎(chǔ)數(shù)據(jù)結(jié)構(gòu)
for ( int i = 0; i < 10; ++i ) {
intDequeQueue.push( i ); //用push函數(shù)將整數(shù)添加到deque容器Queue頂部
}
cout << "Popping from intDequeQueue: ";
popElements( intDequeQueue ); //將Queue中的元素彈出并輸出
cout << endl;
}
template< class T >
void popElements( T &s ) //定義模板函數(shù)
{
while ( !s.empty() ) {
cout << s.front() << ' '; //用函數(shù)front讀取Queue頂上的元素并輸出
s.pop(); //用函數(shù)pop刪除頂上的元素
}
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -