当前位置:网站首页>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;
}
边栏推荐
- allegro,orcad, net alias,port,off-page connector之间的异同点和如何选取
- 交联环糊精金属有机骨架负载甲氨蝶呤缓释微粒|金属-有机多孔材料UiO-66负载黄酮苷类药物|齐岳
- QT learning 24 layout manager (III)
- JS Part III
- 消息订阅与发布
- Print. JS -- web page file printing
- Qt学习24 布局管理器(三)
- 金属有机骨架材料ZIF-8包载姜黄素([email protected]纳米颗粒)|纳米金属有机框架搭载雷帕霉素|科研试剂
- Simulated access
- Go language web development series 25: Gin framework: using MD5 to verify the signature for the interface station
猜你喜欢

金属有机骨架MOFs装载非甾体类抗炎药物|ZIF-8包裹普鲁士蓝负载槲皮素(制备方法)

Use and design of Muduo buffer class

玖逸云黑免费无加密版本源码

Spring cup eight school league

7-9 find a small ball with a balance
[email protected]纳米颗粒)|纳米金属有机框架搭载雷帕霉素|科研试剂"/>金属有机骨架材料ZIF-8包载姜黄素([email protected]纳米颗粒)|纳米金属有机框架搭载雷帕霉素|科研试剂

allegro,orcad, net alias,port,off-page connector之间的异同点和如何选取

全局事件总线

FPGA测试方法以Mentor工具为例

7-7 12-24 hour system
随机推荐
Invalid Z-index problem
Qt学习20 Qt 中的标准对话框(中)
Too many files with unapproved license
Go language web development series 27: Gin framework: using gin swagger to implement interface documents
Go language web development series 26: Gin framework: demonstrates the execution sequence of code when there are multiple middleware
Go language web development series 25: Gin framework: using MD5 to verify the signature for the interface station
Rasp implementation of PHP
7-7 12-24 hour system
Redis: commandes d'action pour les données de type chaîne
JS Part 2
Nucleic acid modified metal organic framework drug carrier | pcn-223 metal organic framework encapsulated ad adamantane | zif-8 encapsulated adriamycin (DOX)
FPGA test method takes mentor tool as an example
Solution to failure or slow downloading of electron when electron uses electron builder to package
Similarities and differences of sessionstorage, localstorage and cookies
Global event bus
Uniapp tips - set background music
page owner特性浅析
Go language web development series 28: solve cross domain access of CORS with gin contrib / CORS
Solve MySQL 1045 access denied for user 'root' @ 'localhost' (using password: yes)
JS get DPI, PX to cm, cm to PX