栈的基本使用方法

 代码:

#include<iostream>
#include<stack>	//栈需要的头文件 
using namespace std;
int main() {
	stack <int> s;	//定义 
	s.push(1);
	s.push(2);
	printf("尺寸:%d\n",s.size());
	printf("空的?:%d\n",s.empty());
	printf("取出:%d\n",s.top());
	s.pop();
	printf("取出:%d\n",s.top());
	printf("新尺寸:%d\n",s.size());
}
//先进后出 

猜你喜欢

转载自blog.csdn.net/LittleWhiteLv/article/details/82695296