当前位置:网站首页>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;
}
边栏推荐
- The small project (servlet+jsp+mysql+el+jstl) completes a servlet with login function, with the operation of adding, deleting, modifying and querying. Realize login authentication, prevent illegal log
- Raft 协议
- Multi person collaborative data annotation based on Baidu brain easydata from scratch
- Qt学习18 登录对话框实例分析
- js 2023. String pair equal to the target string after connection
- Duet date picker (time plug-in that can manually enter the date)
- Scroll detection, so that the content in the lower right corner is not displayed at the top of the page, but is displayed as the mouse slides
- Toast UI editor (editor allows you to edit your markup document using text or WYSIWYG, with syntax highlighting, scrolling synchronization, real-time preview and chart functions.)
- Webpage connection database ~ simple implementation of addition, deletion, modification and query complete code
- selenium 浏览器(1)
猜你喜欢
Qt学习18 登录对话框实例分析
Go language web development series 29: Gin framework uses gin contrib / sessions library to manage sessions (based on cookies)
Solution to failure or slow downloading of electron when electron uses electron builder to package
FPGA test method takes mentor tool as an example
Nucleic acid modified metal organic framework drug carrier | pcn-223 metal organic framework encapsulated ad adamantane | zif-8 encapsulated adriamycin (DOX)
关于回溯问题中的排列问题的思考(LeetCode46题与47题)
八大排序
[email protected](Fe)|甘草次酸修饰金属有机框架材料UiO-66-NH2(简称UiO-66-NH2-GA)"/>
MIL-100( Fe) 包裹小分子阿司匹林形成[email protected](Fe)|甘草次酸修饰金属有机框架材料UiO-66-NH2(简称UiO-66-NH2-GA)
Qt学习23 布局管理器(二)
7-7 12-24 hour system
随机推荐
Go language web development series 29: Gin framework uses gin contrib / sessions library to manage sessions (based on cookies)
7-9 find a small ball with a balance
Cross linked cyclodextrin metal organic framework loaded methotrexate slow-release particles | metal organic porous material uio-66 loaded with flavonoid glycosides | Qiyue
叶酸修饰的金属-有机骨架(ZIF-8)载黄芩苷|金属有机骨架复合磁性材料([email protected])|制备路线
使用vscode查看Hex或UTF-8编码
[acnoi2022] guess numbers
战略、战术(和 OKR)
Uniapp skills - dom display and hiding
全局事件总线
Interface for querying IP home
Invalid Z-index problem
Duet date picker (time plug-in that can manually enter the date)
玖逸云黑免费无加密版本源码
GoLand 2021.2 configure go (go1.17.6)
【吉林大学】考研初试复试资料分享
Redis:Redis的数据结构、key的操作命令
Current situation, analysis and prediction of information and innovation industry
RocksDB LRUCache
好看、好用、强大的手写笔记软件综合评测:Notability、GoodNotes、MarginNote、随手写、Notes Writers、CollaNote、CollaNote、Prodrafts、Noteshelf、FlowUs、OneNote、苹果备忘录
Webpage connection database ~ simple implementation of addition, deletion, modification and query complete code