1.形参的默认值:声明设置,定义不能设置
2.递归函数:
int f(x)
{
if (x足够小)
return;
else
f(比x小);
}
3.汉诺塔递归实现:n个盘保持上方比下方小实现从A到C
void hano(int n, char a, char b, char c)
{
if (n == 1)
{
cout<<a<<" -> "<<c<<endl;
}
else
{
hano(n-1, a, c, b);
hano(1, a, b, c);
hano(n-1, b, a, c);
}
}
4.输入整数,正反显示所有数字,10进制,2进制
void show(int x)
{
if (x > 9)
{
show(x/10);
cout<<" ";
}
cout<<x%10;
}
void show(int x)
{
cout<<x%10;
if (x > 9)
{
cout<<" ";
show(x/10);
}
}
void show(int x)
{
if (x > 1)
{
show(x/2);
cout<<" ";
}
cout<<x%2;
}
5.extern int a;声明一个全局变量,必须在其他某个地方定义
6.静态变量、函数,只能在本文件中使用