当前位置:网站首页>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;
}
边栏推荐
- Summary of common error reporting problems and positioning methods of thrift
- Doxorubicin loaded on metal organic framework MIL-88 DOX | folic acid modified uio-66-nh2 doxorubicin loaded [email
- QT learning 22 layout manager (I)
- QT learning 24 layout manager (III)
- 【吉林大学】考研初试复试资料分享
- JS continues to explore...
- Go language web development series 25: Gin framework: using MD5 to verify the signature for the interface station
- Exercise 6-2 using functions to sum special A-string sequences
- 玖逸云黑免费无加密版本源码
- 7-9 find a small ball with a balance
猜你喜欢

使用vscode查看Hex或UTF-8编码

“又土又穷”的草根高校,凭什么被称为“东北小清华”?

RocksDB LRUCache

Scroll detection of the navigation bar enables the navigation bar to slide and fix with no content

28:第三章:开发通行证服务:11:在配置文件中定义属性,然后在代码中去获取;

jvm-对象生命周期

Spring cup eight school league

Go: send the get request and parse the return JSON (go1.16.4)

Why are grass-roots colleges and universities with "soil and poverty" called "Northeast small Tsinghua"?

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
随机推荐
QT learning 21 standard dialog box in QT (Part 2)
Collection of mobile adaptation related articles
Go language web development series 29: Gin framework uses gin contrib / sessions library to manage sessions (based on cookies)
Comprehensive case of MySQL data addition, deletion, modification and query
JS download files through URL links
Nucleic acid modified metal organic framework drug carrier | pcn-223 metal organic framework encapsulated ad adamantane | zif-8 encapsulated adriamycin (DOX)
Conversion function and explicit
Go language unit test 5: go language uses go sqlmock and Gorm to do database query mock
Exercise 9-3 plane vector addition
Spring cup eight school league
Implementation of Muduo asynchronous logging
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
jvm-对象生命周期
Scroll detection of the navigation bar enables the navigation bar to slide and fix with no content
[ACNOI2022]猜数
Invalid Z-index problem
金属有机骨架MOFs装载非甾体类抗炎药物|ZIF-8包裹普鲁士蓝负载槲皮素(制备方法)
js 2023. String pair equal to the target string after connection
Common network state detection and analysis tools
可编程逻辑器件软件测试