1
0
mirror of https://github.com/renbaoshuo/202401-programming-assignments.git synced 2024-11-27 08:26:20 +00:00
202401-programming-assignments/【实践课内】11.函数2/6-2 递归实现指数函数.md

40 lines
619 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 6-2 递归实现指数函数
本题要求实现一个计算$$x^n$$$$n\ge 1$$)的函数。
### 函数接口定义:
```c++
double calc_pow( double x, int n );
```
函数`calc_pow`应返回`x`的`n`次幂的值。建议用递归实现。题目保证结果在双精度范围内。
### 裁判测试程序样例:
```c++
#include <stdio.h>
double calc_pow( double x, int n );
int main()
{
double x;
int n;
scanf("%lf %d", &x, &n);
printf("%.0f\n", calc_pow(x, n));
return 0;
}
/* 你的代码将被嵌在这里 */
```
### 输入样例:
```in
2 3
```
### 输出样例:
```out
8
```