摘要: 1.前序遍历法 数据结构:stack栈 操作: stack<Node*>st; st.top(); st.pop(); st.emplace(); 2.层次遍历法 数据结构:queue队列 操作: queue<Node*>q; q.front(); q.pop(); q.push(); 阅读全文
posted @ 2023-04-06 19:13 iu本u 阅读(4) 评论(0) 推荐(0)
摘要: 589N叉树遍历 vector<Node*>children; for(auto &ch:children){} stack(Node*)st; Node* node=st.pop(); for(auto it=node->children.rbegin();it!=node.rend();it++ 阅读全文
posted @ 2023-04-06 15:14 iu本u 阅读(20) 评论(0) 推荐(0)
摘要: 利用迭代器 for(auto it=a.begin();a!=a.end();it++){ cout<<*it<<endl; } for_each void func(double x){ cout<<x<<endl; } vector<double>a; for_each(a.begin(),a. 阅读全文
posted @ 2023-04-06 10:22 iu本u 阅读(19) 评论(0) 推荐(0)