C++中栈的用法

简单记忆,具体详细见:https://blog.csdn.net/qq_20366761/article/details/70053813

c++栈的方法的基本用法: 

  1. push(): 向栈内压入一个成员;
  2. pop(): 从栈顶弹出一个成员;
  3. empty(): 如果栈为空返回true,否则返回false;
  4. top(): 返回栈顶,但不删除成员;
  5. size(): 返回栈内元素的大小;
#include
#include
using namespace std;

int main(){
	stack  stk;
	for(int i=0;i<10;i++){
		stk.push(i);
	}
	cout<

 

你可能感兴趣的:(1,大学学习的算法)