c语言编程n次方怎么表示

如题所述

第1个回答  2012-02-26
pow(x,n);
x的n次方
第2个回答  2012-02-26
加头文件math.h,例如m的n次方可以利用函数pow(m, n);
第3个回答  2012-02-26
for (i = 0; i < n; i++)
{
result *= num; // num 为底数,n 为幂, result 为结果
}
第4个回答  推荐于2017-09-26
C语言中的数学函数:pow
  原型:在TC2.0中原型为extern float pow(float x, float y); ,而在VC6.0中原型为double pow( double x, double y );
  头文件:math.h
  功能:计算x的y次幂。
  返回值:x应大于零,返回幂指数的结果。
  举例1:(在VC6.0中运行通过)
  #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;
  }
  举例2: (在TC2.0中运行通过)
  // pow.c
  #include <syslib.h>
  #include <math.h>
  main()
  {
  clrscr(); // clear screen
  textmode(0x00); // 6 lines per LCD screen
  printf("4^5=%f",pow(4.,5.));
  getchar();
  return 0;
  }本回答被提问者采纳

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网