You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
# include <bits/stdc++.h>
using namespace std ;
/*
知识点内容: C++ STL 栈和队列详解
栈是一种特殊的线性表。其特殊性在于限定插入和删除数据元素的操作只能在线性表的一端进行。
队列(Queue)也是一种运算受限的线性表,它的运算限制与栈不同,是两头都有限制,插入只能在表的一端进行(只进不出),
而删除只能在表的另一端进行(只出不进),允许删除的一端称为队尾(rear),允许插入的一端称为队头 (Front),
文档内容参考:
https://www.cnblogs.com/aiguona/p/7200837.html
* */
int main ( )
{
//队列
queue < int > q ;
//栈
stack < char > s ;
//放入第一个元素1
q . push ( 1 ) ;
//判断是不是为空
cout < < q . empty ( ) < < endl ; //如果栈为空返回true, 否则返回false
//放入第二个元素2
q . push ( 2 ) ;
cout < < q . front ( ) < < endl ;
q . pop ( ) ;
// 返回队首元素的值,但不删除该元素
cout < < q . front ( ) < < endl ;
//删除队列首元素但不返回其值
q . pop ( ) ;
//如果栈为空返回true, 否则返回false
cout < < q . empty ( ) < < endl ;
//======================================================================
//存入元素2
s . push ( 2 ) ;
cout < < s . top ( ) < < endl ;
//返回栈顶的元素,但不删除该元素
s . push ( 3 ) ;
cout < < s . top ( ) ;
s . pop ( ) ;
cout < < s . top ( ) ;
}