当前位置:网站首页>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;
}
边栏推荐
- Page generation QR code
- Go language web development series 27: Gin framework: using gin swagger to implement interface documents
- JS first summary
- Rasp implementation of PHP
- Use vscode to view hex or UTF-8 codes
- [Jilin University] information sharing of postgraduate entrance examination and re examination
- JS shift operators (< <,> > and > > >)
- 7-9 find a small ball with a balance
- Implementation of Muduo asynchronous logging
- Go language web development series 26: Gin framework: demonstrates the execution sequence of code when there are multiple middleware
猜你喜欢

Nucleic acid modified metal organic framework drug carrier | pcn-223 metal organic framework encapsulated ad adamantane | zif-8 encapsulated adriamycin (DOX)

JS first summary

全局事件总线

Implementation of Muduo accept connection, disconnection and sending data

消息订阅与发布

concat和concat_ws()区别及group_concat()和repeat()函数的使用

Leetcode(4)——寻找两个正序数组的中位数

交联环糊精金属有机骨架负载甲氨蝶呤缓释微粒|金属-有机多孔材料UiO-66负载黄酮苷类药物|齐岳

Redis: commandes d'action pour les données de type chaîne

Multi person collaborative data annotation based on Baidu brain easydata from scratch
随机推荐
1px problem of mobile terminal
Common plug-ins for vite project development
QT learning 19 standard dialog box in QT (top)
使用vscode查看Hex或UTF-8编码
Using registered classes to realize specific type matching function template
玖逸云黑免费无加密版本源码
“又土又穷”的草根高校,凭什么被称为“东北小清华”?
Go language web development series 25: Gin framework: using MD5 to verify the signature for the interface station
Go 1.16.4: purpose of go mod tidy
Go language web development series 26: Gin framework: demonstrates the execution sequence of code when there are multiple middleware
FPGA test method takes mentor tool as an example
JVM runtime data area
小项目(servelt+jsp+mysql+EL+JSTL)完成一个登录功能的Servlet,具有增删改查的操作。实现登录身份验证,防止非法登录,防止多点登录,记住用户名密码功能。
JS matrix zero
Failure of vector insertion element iterator in STL
Thrift threadmanager and three monitors
Analysis of the characteristics of page owner
Comprehensive case of MySQL data addition, deletion, modification and query
Cross linked cyclodextrin metal organic framework loaded methotrexate slow-release particles | metal organic porous material uio-66 loaded with flavonoid glycosides | Qiyue
QT learning 25 layout manager (4)