1000字范文,内容丰富有趣,学习的好帮手!
1000字范文 > C语言 求pow()函数 x的y次方

C语言 求pow()函数 x的y次方

时间:2019-11-17 01:09:05

相关推荐

C语言 求pow()函数 x的y次方

头文件:

#include<math.h>

pow() 函数用来求 x 的 y 次幂(次方),其原型为:double pow(double x, double y);

求x的y次方也就是y个x累乘。

代码如下:

#include<stdio.h>#include<math.h>double My_Pow(double x, int y);int main(){int a , b;scanf("%d %d", &a, &b);printf("%f", My_Pow(a , b));}double My_Pow(double x, int y){int tmp = 1;for(int i = 0; i < y; i++){tmp *= x;} return tmp;}

运行结果展示:

2 664.000000

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。