当前位置:网站首页>[C language] simulation implementation of pow function (recursion)
[C language] simulation implementation of pow function (recursion)
2022-07-28 20:03:00 【An ran_】
One 、 Library function ——pow Function function introduction and use demonstration
1.API Explanation in the document
(1) function :Calculates x raised to the power of y. Computation x Of y Power
(2) Parameters : base:Base value. Cardinality
exponent:Exponent value. The index
(3) Return value :pow returns the value of xy. No error message is printed
on overflow or underflow namely Pow return xy Value . No error message will be printed when overflow or underflow .(4) The header file :<math.h>
(5) Compatibility :ANSI, Win 95, Win NT
(6) Abstract :The pow function computes x raised to the power of y.
namely pow Function calculation x Of y Powerpow does not recognize integral floating-point values greater than 264, such as
1.0E100. namely pow Cannot identify greater than 264 Integer floating point value of , for example 1.0E100.
2.pow Function use demonstration
#include <math.h>
#include <stdio.h>
int main()
{
double x = 2.0, y = 3.0, z;
z = pow( x, y );
printf( "%.1f to the power of %.1f is %.1f\n", x,y,z);
return 0;
}
![[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-N6t5yeSs-1651400700392)(C:\Users\19271\AppData\Roaming\Typora\typora-user-images\image-20220501180606209.png)]](/img/7b/ef8b3d97adc7810de249a37642c71f.png)
Two 、pow Simulation Implementation of function
Realize the idea :![[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-LSxan8nM-1651400652980)(C:\Users\19271\AppData\Roaming\Typora\typora-user-images\image-20220501181809076.png)]](/img/43/2d1aefdc0f0b45a4a08dc422e707d7.png)
#include <stdio.h>
double Pow(int n,int k)
{
if (k > 0)
return n * Pow(n, k - 1);
else if (k == 0)
return 1;
else
return 1.0 / Pow(n, -k);
}
int main()
{
int n ,k;
scanf("%d%d", &n,&k);
double ret = Pow(n, k);
printf("%.2lf\n",ret);
return 0;
}
![[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-ZItZYIsh-1651400652981)(C:\Users\19271\AppData\Roaming\Typora\typora-user-images\image-20220501181054130.png)]](/img/39/6f8dedb34ad6eb70a3ff35f33a0ffe.png)
3、 ... and 、 Add
1.API What is the document ?
In short, it is For all API A clear explanation of the call and the parameters involved .. To be specific , It's every one API What can be done , And right API
Explanation of each parameter in , Including their types 、 Format 、 Possible values 、 Validation rule 、 Whether it is necessary, etc .
Reference resources : https://zhuanlan.zhihu.com/p/36729484#:~:text=API
2. Suggestions for naming custom functions in simulation implementation
Distinguish between upper and lower case letters , It's best not to conflict with the naming of library functions .
边栏推荐
- 软考高级考试中有五大证书,哪个更值得考?
- Using Lex (Flex) to generate lexical analyzer of PL language
- MySQL8 基于clone创建主从复制
- This customized keyboard turns me on~
- C language pointer and two-dimensional array
- How navicate modifies the database name
- Leetcode Day1 score ranking
- There is a 'single quotation mark' problem in the string when Oracle inserts data
- MySQL command statement (personal summary)
- English translation Arabic - batch English translation Arabic tools free of charge
猜你喜欢

架构基本概念和架构本质
![[NPP installation plug-in]](/img/6f/97e53116ec4ebc6a6338d125ddad8b.png)
[NPP installation plug-in]

克服“看牙恐惧”,我们用技术改变行业

KubeEdge发布云原生边缘计算威胁模型及安全防护技术白皮书

Servlet学习笔记

Can China make a breakthrough in the future development of the meta universe and occupy the highland?

Common APIs in string

基于C语言的信息管理系统和小游戏

Thoroughly understand bit operations - shift left, shift right

editor.md中markdown编辑器的实现
随机推荐
MySQL命令语句(个人总结)
MySQL8 Status Variables: Internal Temporary Tables and Files
leetcode day5 删除重复的电子邮箱
BeanFactory not initialized or already closed - call ‘refresh‘ before accessing beans via the Applic
High beam software has obtained Alibaba cloud product ecological integration certification, and is working with Alibaba cloud to build new cooperation
爬取IP
The results of the second quarter online moving people selection of "China Internet · moving 2022" were announced
中国能否在元宇宙的未来发展中取得突破,占领高地?
C+ + core programming
11. Learn MySQL union operator
Labelme(一)
MySQL8 Encrypting InnoDB Tablespaces
Integration and implementation of login click graphic verification code in personal blog system
Implementation of memcpy in C language
[network] communication across regional networks learn how routing tables work
Crawl IP
Redis笔记
Array method added in ES6
Function fitting based on MATLAB
There are five certificates in the soft examination advanced examination, which is more worth taking?