当前位置: 技术问答>linux和unix
刚学LINUX下C语言,数学函数的小问题!
来源: 互联网 发布时间:2015-08-14
本文导语: # include "math.h" main() { float a,b,c,s,area; scanf("%f,%f,%f",&a,&b,&c); s=1.0/2*(a+b+c); area=sqrt(s*(s-a)*(s-b)*(s-c)); printf("a=%7.2f,b=%7.2f,c=%7.2f,s=%7.2fn",a,b,c,s); p...
# include "math.h"
main()
{
float a,b,c,s,area;
scanf("%f,%f,%f",&a,&b,&c);
s=1.0/2*(a+b+c);
area=sqrt(s*(s-a)*(s-b)*(s-c));
printf("a=%7.2f,b=%7.2f,c=%7.2f,s=%7.2fn",a,b,c,s);
printf("area=%7.2fn",area);
}
编译提示:
/tmp/ccMQuYfg.o(.text+0x61): In function `main':
: undefined reference to `sqrt'
collect2: ld returned 1 exit status
应该是SQRT的数学函数没找到吧.大家帮帮助.
main()
{
float a,b,c,s,area;
scanf("%f,%f,%f",&a,&b,&c);
s=1.0/2*(a+b+c);
area=sqrt(s*(s-a)*(s-b)*(s-c));
printf("a=%7.2f,b=%7.2f,c=%7.2f,s=%7.2fn",a,b,c,s);
printf("area=%7.2fn",area);
}
编译提示:
/tmp/ccMQuYfg.o(.text+0x61): In function `main':
: undefined reference to `sqrt'
collect2: ld returned 1 exit status
应该是SQRT的数学函数没找到吧.大家帮帮助.
|
gcc -o aaa aaa.c -lm
linux下使用数学库必须加-lm进行编译
linux下使用数学库必须加-lm进行编译
|
#include