另外c语言中,math.h文件中含有乘方(包括开方)的库函数,是pow(x,y)
其中x和y都是双精度浮点(double)型,x是底数,y是指数(如果是小数即为开方)
这样写就可以了:double fun_x3 (double x) { return x*x*x}
程序例子,计算2的3次方。
#include <stdio.h>
double fun_x3 (double x) { return x*x*x}
int main(){
double y
int x=2
y = fun_x3(x) //用 fun_x3(x) 或 fun_x3(2) 调用即可
printf("%g ", y ) // %g 是自动优化格式
return 0
}