最基础的“穷竭搜索”(2,栈)

来源:互联网 发布:农村淘宝开业剪彩流程 编辑:程序博客网 时间:2024/06/03 12:54

(1)递归函数的递归过程就可以用栈来解决。下面是栈的基础操作代码
(2)代码:

#include<iostream>#include<stack>using namespace std;int main(){    ios::sync_with_stdio(false);cin.tie(0);    stack<int> s;    s.push(1);    s.push(2);    s.push(3);    cout<<s.top();    s.pop();    cout<<s.top();    s.pop();    cout<<s.top();}
原创粉丝点击