数学库函数的连接问题
我的代码如下#include<stdio.h>
#include<math.h>
#define PI 3.1415926
float judge(float a,float b,float c)
{
float e,A;
e=(pow(a,2)+pow(b,2)-pow(c,2))/2/a/b;
if(e>1||e<-1)
printf("error!\n");
else
return A=acos(e);
}
float main()
{
float a,b,c,A,B,C;
printf("input three numbers:\n");
scanf("%f%f%f",&a,&b,&c);
A=judge(a,b,c);
B=judge(b,c,a);
C=judge(a,c,b);
if(A==(PI/4)||B==(PI/4)||C==(PI/4))
printf("this is an zhijiao\n");
else if(A>PI/4||B>PI/4||C>PI/4)
printf("this is an dunjiao\n");
else if(A<PI/4&&B<PI/4&&C<PI/4)
printf("this is a ruijiao\n");
return;
}
在终端输入gcc -g -lm triangle.c 就会出现如下错误
/tmp/cc16oWLv.o: In function `judge':
/home/menshuai/desktop/triangle.c:11: undefined reference to `acos'
collect2: ld 返回 1
在搜多引擎搜了一下 没有满意度答案 求帮忙~~~~~