# 根据下面递归函数：调用函数Fun(2)，返回值是多少（ ）

``````int Fun(int n)
{
if (n == 5)
return 2;
else
return 2 * Fun(n + 1);
}
int main()
{
int n = 2;
int ret = Fun(n);
printf("%d\n", ret);
return 0;
}
``````

A.2
B.4
C.8
D.16

# 作业标题

``````char arr[] = "abcdef";

``````

strlen函数可以自己写一个，这里我懒，就没写了

``````void reverse(char* str, int left, int right)
{
char  tmp = str[left];
str[left] = str[right];
str[right] = tmp;
if (left < right)
{
reverse(str, left + 1, right - 1);
}
}
int main()
{
char arr[] = "abcdefg";
int left = 0;
int right = strlen(arr) - 1;
reverse(arr, left, right);
printf("%s\n", arr);
return 0;
}
``````

# 计算一个数的每位之和（递归实现）

``````int DigitSum(int n)
{
if (n > 9)
return DigitSum(n / 10) + n % 10;
else
return n;
}
int main()
{
int n = 1729;
int ret = DigitSum(n);
printf("%d\n", ret);
return 0;
}
``````

# 递归实现n的k次方

``````double pow(int n, int k)
{
if (k > 0)
return n * pow(n, k - 1);
else if (k == 0)
return 1;
else
return 1.0 * pow(n, -k);
}
int main()
{
int n = 2;
int k = 3;
double ret = pow(n, k);
printf("%lf\n", ret);
}
``````