|
# include "math.h"
# include "stdio.h"
main ()
{ float a,b,c,s,area;
int t=1;
printf ("请输入三角形的三条边长,中间用逗号隔开");
scanf ("%f,%f,%f",&a,&b,&c);
if (t=a+b>c&&a+c>b&&c+b>a)
{ s=0.5*(a+b+c);
area=sqrt(s*(s-a)*(s-b)*(s-c));
printf ("a=%7.2f,b=%7.2f,c=%7.2f,s=%7.2f\n",a,b,c,s);
printf ("area=%7.2f\n ",area); }
else
printf ("这个不是三角形"); }
[lhd@localhost c]$ gcc tri.c -o tri
/tmp/cc2QoTTc.o: In function `main':
tri.c .text+0x10e): undefined reference to `sqrt'
collect2: ld 返回 1
以上的程序编译时出现错误,sqrt因该是数学函数库里的根号吧,难道在Linux下根号的写法不一样吗?请DX帮个忙,解译一下!谢谢! |
|