STL之stack
1 ``` 2 #include<iostream> 3 #include<algorithm> 4 #include<stack> 5 #include<cstring> 6 #include<cstdlib> 7 using namespace std; 8 9 void test01(){ 10 //初始化 11 stack<int> s1; 12 stack<int> s2(s1); 13 14 //stack操作 15 s1.push(10); 16 s1.push(20); 17 s1.push(30); 18 s1.push(100); 19 cout<<"栈顶元素:"<<s1.top()<<endl; 20 s1.pop();//删除栈顶元素 21 22 //打印栈容器数据 23 while(!s1.empty()){ 24 cout<<s1.top()<<" "; 25 s1.pop(); 26 } 27 cout<<endl; 28 cout<<"size:"<<s1.size()<<endl; 29 30 } 31 32 int main() 33 { 34 test01(); 35 36 return 0; 37 } 38 39 ```
有些目标看似很遥远,但只要付出足够多的努力,这一切总有可能实现!