
C++中pow(x,y)函数怎么用?最好给举个例子…
6个回答
展开全部
原型:在TC2.0中原型为extern float pow(float x, float y); ,而在VC6.0中原型为double pow( double x, double y );
头文件:math.h
功能:计算x的y次幂。
返回值:x应大于零,返回幂指数的结果。
返回类型:double型,int,float会给与警告!
举例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;
}
参考于:http://baike.baidu.com/view/114061.htm
头文件:math.h
功能:计算x的y次幂。
返回值:x应大于零,返回幂指数的结果。
返回类型:double型,int,float会给与警告!
举例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;
}
参考于:http://baike.baidu.com/view/114061.htm
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询