<?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=03-%E8%BF%9B%E9%98%B6%E5%9F%BA%E7%A1%80%2F03-%E5%87%BD%E6%95%B0</id>
	<title>03-进阶基础/03-函数 - 版本历史</title>
	<link rel="self" type="application/atom+xml" href="https://www.33dai.wiki/index.php?action=history&amp;feed=atom&amp;title=03-%E8%BF%9B%E9%98%B6%E5%9F%BA%E7%A1%80%2F03-%E5%87%BD%E6%95%B0"/>
	<link rel="alternate" type="text/html" href="https://www.33dai.wiki/index.php?title=03-%E8%BF%9B%E9%98%B6%E5%9F%BA%E7%A1%80/03-%E5%87%BD%E6%95%B0&amp;action=history"/>
	<updated>2026-05-20T23:08:27Z</updated>
	<subtitle>本wiki上该页面的版本历史</subtitle>
	<generator>MediaWiki 1.45.1</generator>
	<entry>
		<id>https://www.33dai.wiki/index.php?title=03-%E8%BF%9B%E9%98%B6%E5%9F%BA%E7%A1%80/03-%E5%87%BD%E6%95%B0&amp;diff=321&amp;oldid=prev</id>
		<title>33DAI：​导入1个版本</title>
		<link rel="alternate" type="text/html" href="https://www.33dai.wiki/index.php?title=03-%E8%BF%9B%E9%98%B6%E5%9F%BA%E7%A1%80/03-%E5%87%BD%E6%95%B0&amp;diff=321&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-320:rev-321 --&gt;
&lt;/table&gt;</summary>
		<author><name>33DAI</name></author>
	</entry>
	<entry>
		<id>https://www.33dai.wiki/index.php?title=03-%E8%BF%9B%E9%98%B6%E5%9F%BA%E7%A1%80/03-%E5%87%BD%E6%95%B0&amp;diff=320&amp;oldid=prev</id>
		<title>-&gt;Importer：​批量导入三三文档</title>
		<link rel="alternate" type="text/html" href="https://www.33dai.wiki/index.php?title=03-%E8%BF%9B%E9%98%B6%E5%9F%BA%E7%A1%80/03-%E5%87%BD%E6%95%B0&amp;diff=320&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;tr class=&quot;diff-title&quot; lang=&quot;zh-Hans-CN&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;←上一版本&lt;/td&gt;
				&lt;td colspan=&quot;1&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;2&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;/table&gt;</summary>
		<author><name>-&gt;Importer</name></author>
	</entry>
	<entry>
		<id>https://www.33dai.wiki/index.php?title=03-%E8%BF%9B%E9%98%B6%E5%9F%BA%E7%A1%80/03-%E5%87%BD%E6%95%B0&amp;diff=221&amp;oldid=prev</id>
		<title>33DAI：​导入1个版本</title>
		<link rel="alternate" type="text/html" href="https://www.33dai.wiki/index.php?title=03-%E8%BF%9B%E9%98%B6%E5%9F%BA%E7%A1%80/03-%E5%87%BD%E6%95%B0&amp;diff=221&amp;oldid=prev"/>
		<updated>2026-05-20T16:25:17Z</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;tr class=&quot;diff-title&quot; lang=&quot;zh-Hans-CN&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;←上一版本&lt;/td&gt;
				&lt;td colspan=&quot;1&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;2&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;/table&gt;</summary>
		<author><name>33DAI</name></author>
	</entry>
	<entry>
		<id>https://www.33dai.wiki/index.php?title=03-%E8%BF%9B%E9%98%B6%E5%9F%BA%E7%A1%80/03-%E5%87%BD%E6%95%B0&amp;diff=220&amp;oldid=prev</id>
		<title>-&gt;Importer：​批量导入三三文档</title>
		<link rel="alternate" type="text/html" href="https://www.33dai.wiki/index.php?title=03-%E8%BF%9B%E9%98%B6%E5%9F%BA%E7%A1%80/03-%E5%87%BD%E6%95%B0&amp;diff=220&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;
== 函数基础 ==&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;
void sayHello()&lt;br /&gt;
{&lt;br /&gt;
    cout &amp;lt;&amp;lt; &amp;quot;Hello!\n&amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
    sayHello(); // 调用函数&lt;br /&gt;
    sayHello(); // 可以多次调用&lt;br /&gt;
    return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;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;
// 返回两个整数的最大值&lt;br /&gt;
int max(int a, int b)&lt;br /&gt;
{&lt;br /&gt;
    if (a &amp;gt; b)&lt;br /&gt;
        return a;&lt;br /&gt;
    return b;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
    cout &amp;lt;&amp;lt; max(3, 5); // 输出 5&lt;br /&gt;
    return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 函数定义语法 ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
返回类型 函数名(参数类型1 参数名1, 参数类型2 参数名2, ...)&lt;br /&gt;
{&lt;br /&gt;
    // 函数体&lt;br /&gt;
    return 返回值;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 参数传引用 ===&lt;br /&gt;
&lt;br /&gt;
默认情况下，参数是&amp;#039;&amp;#039;&amp;#039;传值&amp;#039;&amp;#039;&amp;#039;的（复制一份），修改参数不会影响原来的变量。&lt;br /&gt;
&lt;br /&gt;
使用 &amp;lt;code&amp;gt;&amp;amp;&amp;lt;/code&amp;gt; 可以&amp;#039;&amp;#039;&amp;#039;传引用&amp;#039;&amp;#039;&amp;#039;，函数内对参数的修改会影响原来的变量：&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void swap(int &amp;amp;a, int &amp;amp;b)&lt;br /&gt;
{&lt;br /&gt;
    int t = a;&lt;br /&gt;
    a = b;&lt;br /&gt;
    b = t;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
    int x = 3, y = 5;&lt;br /&gt;
    swap(x, y);&lt;br /&gt;
    cout &amp;lt;&amp;lt; x &amp;lt;&amp;lt; &amp;quot; &amp;quot; &amp;lt;&amp;lt; y; // 输出 5 3&lt;br /&gt;
    return 0;&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;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int max(int a, int b) { return a &amp;gt; b ? a : b; }&lt;br /&gt;
double max(double a, double b) { return a &amp;gt; b ? a : b; }&lt;br /&gt;
int max(int a, int b, int c) { return max(max(a, b), c); }&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;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int add(int a, int b); // 声明（函数原型）&lt;br /&gt;
&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
    cout &amp;lt;&amp;lt; add(3, 5);&lt;br /&gt;
    return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
int add(int a, int b) // 定义&lt;br /&gt;
{&lt;br /&gt;
    return a + b;&lt;br /&gt;
}&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>