首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

这个求方程式子为什么编译通不过?该怎么解决

2012-03-02 
这个求方程式子为什么编译通不过?#includestdio.h#includemath.hintmain(){floatx,yprintf( Thispro

这个求方程式子为什么编译通不过?
#include   <stdio.h>
#include   <math.h>
int   main()
{
        float   x,   y;

        printf( "This   programe   calculate   y   =   3x^5   -   2x^3   +   x\n\n ");
        printf( "x   value         y   value\n ");
        printf( "-------         -------\n ");

        for(x   =   5.0;   x   <=   10.0;   x   +=   0.2)
        {
                y   =   3.0   *   pow(x,   5)   -   2.0   *   pow(x,   3)   +   x;
                printf( "%8.6f         %13.6f\n ",   x,   y);
        }

        return   0;
}

===========================
编译出错如下:

$   gcc   -o   5_5_9   5_5_9a.c
/tmp/ccIbN56l.o:   In   function   `main ':
5_5_9a.c:(.text+0x4c):   undefined   reference   to   `pow '
5_5_9a.c:(.text+0x90):   undefined   reference   to   `pow '
collect2:   ld   返回   1


我是在看不出来为什么pow函数有问题了...

[解决办法]
没有包含pow函数的头文件~
[解决办法]
可能你的编译环境中的pow函数不在math.h中,试一下引用stdlib.h
在我的环境中,pow是在math.h中
[解决办法]
pow,数学方面的运算,是在 math.h 里面。
[解决办法]
精度问题呀.float型精度很低的.

热点排行