<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="zh-Hans-CN">
	<id>https://www.33dai.wiki/index.php?action=history&amp;feed=atom&amp;title=04-%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84%2F03-stack</id>
	<title>04-数据结构/03-stack - 版本历史</title>
	<link rel="self" type="application/atom+xml" href="https://www.33dai.wiki/index.php?action=history&amp;feed=atom&amp;title=04-%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84%2F03-stack"/>
	<link rel="alternate" type="text/html" href="https://www.33dai.wiki/index.php?title=04-%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84/03-stack&amp;action=history"/>
	<updated>2026-05-20T23:07:29Z</updated>
	<subtitle>本wiki上该页面的版本历史</subtitle>
	<generator>MediaWiki 1.45.1</generator>
	<entry>
		<id>https://www.33dai.wiki/index.php?title=04-%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84/03-stack&amp;diff=335&amp;oldid=prev</id>
		<title>33DAI：​导入1个版本</title>
		<link rel="alternate" type="text/html" href="https://www.33dai.wiki/index.php?title=04-%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84/03-stack&amp;diff=335&amp;oldid=prev"/>
		<updated>2026-05-20T18:12:09Z</updated>

		<summary type="html">&lt;p&gt;导入1个版本&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;zh-Hans-CN&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;←上一版本&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;2026年5月20日 (三) 18:12的版本&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;4&quot; class=&quot;diff-notice&quot; lang=&quot;zh-Hans-CN&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;（没有差异）&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;!-- diff cache key my_wiki:diff:1.41:old-334:rev-335 --&gt;
&lt;/table&gt;</summary>
		<author><name>33DAI</name></author>
	</entry>
	<entry>
		<id>https://www.33dai.wiki/index.php?title=04-%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84/03-stack&amp;diff=334&amp;oldid=prev</id>
		<title>-&gt;Importer：​批量导入三三文档</title>
		<link rel="alternate" type="text/html" href="https://www.33dai.wiki/index.php?title=04-%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84/03-stack&amp;diff=334&amp;oldid=prev"/>
		<updated>2026-05-20T16:50:33Z</updated>

		<summary type="html">&lt;p&gt;批量导入三三文档&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;zh-Hans-CN&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;←上一版本&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;2026年5月20日 (三) 16:50的版本&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;4&quot; class=&quot;diff-notice&quot; lang=&quot;zh-Hans-CN&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;（没有差异）&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;!-- diff cache key my_wiki:diff:1.41:old-235:rev-334 --&gt;
&lt;/table&gt;</summary>
		<author><name>-&gt;Importer</name></author>
	</entry>
	<entry>
		<id>https://www.33dai.wiki/index.php?title=04-%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84/03-stack&amp;diff=235&amp;oldid=prev</id>
		<title>33DAI：​导入1个版本</title>
		<link rel="alternate" type="text/html" href="https://www.33dai.wiki/index.php?title=04-%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84/03-stack&amp;diff=235&amp;oldid=prev"/>
		<updated>2026-05-20T16:25:25Z</updated>

		<summary type="html">&lt;p&gt;导入1个版本&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;zh-Hans-CN&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;←上一版本&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;2026年5月20日 (三) 16:25的版本&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;4&quot; class=&quot;diff-notice&quot; lang=&quot;zh-Hans-CN&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;（没有差异）&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;!-- diff cache key my_wiki:diff:1.41:old-234:rev-235 --&gt;
&lt;/table&gt;</summary>
		<author><name>33DAI</name></author>
	</entry>
	<entry>
		<id>https://www.33dai.wiki/index.php?title=04-%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84/03-stack&amp;diff=234&amp;oldid=prev</id>
		<title>-&gt;Importer：​批量导入三三文档</title>
		<link rel="alternate" type="text/html" href="https://www.33dai.wiki/index.php?title=04-%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84/03-stack&amp;diff=234&amp;oldid=prev"/>
		<updated>2026-05-20T16:22:29Z</updated>

		<summary type="html">&lt;p&gt;批量导入三三文档&lt;/p&gt;
&lt;p&gt;&lt;b&gt;新页面&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&lt;br /&gt;
栈是一种&amp;#039;&amp;#039;&amp;#039;后进先出（LIFO）&amp;#039;&amp;#039;&amp;#039;的数据结构。&lt;br /&gt;
&lt;br /&gt;
=== 定义 ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
stack&amp;lt;int&amp;gt; sta;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 常用操作 ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! 操作 !! 说明&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;sta.push(x)&amp;lt;/code&amp;gt;&lt;br /&gt;
| 将 &amp;lt;code&amp;gt;x&amp;lt;/code&amp;gt; 压入栈顶&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;sta.pop()&amp;lt;/code&amp;gt;&lt;br /&gt;
| 弹出栈顶元素&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;sta.top()&amp;lt;/code&amp;gt;&lt;br /&gt;
| 返回栈顶元素&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;sta.size()&amp;lt;/code&amp;gt;&lt;br /&gt;
| 返回元素数量&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;sta.empty()&amp;lt;/code&amp;gt;&lt;br /&gt;
| 判断是否为空&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== 示例 ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
stack&amp;lt;int&amp;gt; sta;&lt;br /&gt;
sta.push(1);&lt;br /&gt;
sta.push(2);&lt;br /&gt;
sta.push(3);&lt;br /&gt;
&lt;br /&gt;
while (!sta.empty())&lt;br /&gt;
{&lt;br /&gt;
    cout &amp;lt;&amp;lt; sta.top() &amp;lt;&amp;lt; &amp;quot; &amp;quot;; // 输出 3 2 1&lt;br /&gt;
    sta.pop();&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 栈的典型应用 ===&lt;br /&gt;
&lt;br /&gt;
- 括号匹配&lt;br /&gt;
- 表达式求值&lt;br /&gt;
- DFS（深度优先搜索）的非递归实现&lt;br /&gt;
- 单调栈&lt;br /&gt;
&lt;br /&gt;
=== 手写栈 ===&lt;br /&gt;
&lt;br /&gt;
可以用数组模拟栈：&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int stk[1005];&lt;br /&gt;
int top = 0; // 栈顶指针&lt;br /&gt;
&lt;br /&gt;
void push(int x) { stk[++top] = x; }&lt;br /&gt;
void pop() { top--; }&lt;br /&gt;
int getTop() { return stk[top]; }&lt;br /&gt;
bool empty() { return top == 0; }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:数据结构]]&lt;br /&gt;
[[Category:三三文档]]&lt;/div&gt;</summary>
		<author><name>-&gt;Importer</name></author>
	</entry>
</feed>