当前位置:网站首页>Exercise 10-3 recursive implementation of exponential functions
Exercise 10-3 recursive implementation of exponential functions
2022-07-03 14:09:00 【ᯤ⁹ᴳ⁺ ·】
exercises 10-3 Recursive implementation of exponential function (15 branch )
This problem requires the realization of a calculation xn(n≥1) Function of .
Function interface definition :
double calc_pow( double x, int n );
function calc_pow
Should return x
Of n
The value of the power . It is suggested to use recursion to realize . The problem is to ensure that the results are within the double precision range .
Sample referee test procedure :
#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;
}
/* Your code will be embedded here */
sample input :
2 3
sample output :
8
double calc_pow( double x, int n ){
double s;
if(n==0){
s=1;
}else{
s=x*calc_pow(x,n-1);
}
return s;
}
边栏推荐
- Using registered classes to realize specific type matching function template
- Go language web development series 27: Gin framework: using gin swagger to implement interface documents
- Use vscode to view hex or UTF-8 codes
- 如何使用lxml判断网站公告是否更新
- Dynamic programming 01 knapsack and complete knapsack
- Mysql:insert date:sql error [1292] [22001]: data truncation: incorrect date value:
- Cross linked cyclodextrin metal organic framework loaded methotrexate slow-release particles | metal organic porous material uio-66 loaded with flavonoid glycosides | Qiyue
- JS continues to explore...
- 金属有机骨架材料ZIF-8包载姜黄素([email protected]纳米颗粒)|纳米金属有机框架搭载雷帕霉素|科研试剂
- 核酸修饰的金属有机框架药物载体|PCN-223金属有机骨架包载Ad金刚烷|ZIF-8包裹阿霉素(DOX)
猜你喜欢
Nucleic acid modified metal organic framework drug carrier | pcn-223 metal organic framework encapsulated ad adamantane | zif-8 encapsulated adriamycin (DOX)
JS Part III
信创产业现状、分析与预测
FPGA测试方法以Mentor工具为例
JS input number and standard digit number are compared. The problem of adding 0 to 0
Why are grass-roots colleges and universities with "soil and poverty" called "Northeast small Tsinghua"?
Qt学习24 布局管理器(三)
Rasp implementation of PHP
金属有机骨架MOFs装载非甾体类抗炎药物|ZIF-8包裹普鲁士蓝负载槲皮素(制备方法)
Redis:字符串類型數據的操作命令
随机推荐
1px problem of mobile terminal
Global event bus
Go language web development series 26: Gin framework: demonstrates the execution sequence of code when there are multiple middleware
JS continues to explore...
Webpage connection database ~ simple implementation of addition, deletion, modification and query complete code
28:第三章:开发通行证服务:11:在配置文件中定义属性,然后在代码中去获取;
selenium 浏览器(1)
jvm-类加载
Formation of mil-100 (FE) coated small molecule aspirin [email protected] (FE) | glycyrrhetinic acid modified metal organ
Folic acid modified metal organic framework (zif-8) baicalin loaded metal organic framework composite magnetic material (AU- [email
Installation impression notes
QT learning 24 layout manager (III)
JVM object lifecycle
信创产业现状、分析与预测
Redis: redis data structure and key operation commands
Analysis of the characteristics of page owner
Message subscription and publishing
TS code automatically generates JS
Common plug-ins for vite project development
JS Part III