C语言中N次方怎么打

如题所述

有两个函数可以实现,double pow(double x, double y),double pow10(int p)
下面是这两个函数的使用方法,个人建议用:pow10(n)
函数名: pow
功 能: 指数函数(x的y次方)
用 法: double pow(double x, double y);
程序例:
#include <math.h>
#include <stdio.h>
int main(void)
{
double x = 2.0, y = 3.0;
printf("%lf raised to %lf is %lf\n", x, y, pow(x, y));
return 0;
}
函数名: pow10
功 能: 指数函数(10的p次方)
用 法: double pow10(int p);
程序例:
#include <math.h>
#include <stdio.h>
int main(void)
{
double p = 3.0;
printf("Ten raised to %lf is %lf\n", p, pow10(p));
return 0;
}
温馨提示:答案为网友推荐,仅供参考