一个参考程序:已知三点坐标,计算边长和角度;如下:
#include<stdio.h>
#include<math.h>
void main()
{
double a1,a2,b1,b2,c1,c2,a,b,c,A,B,C;
scanf("%lf%lf%lf%lf%lf%lf",&a1,&a2,&b1,&b2,&c1,&c2);
a=sqrt((b1-c1)*(b1-c1)+(b2-c2)*(b2-c2));
b=sqrt((a1-c1)*(a1-c1)+(a2-c2)*(a2-c2));
c=sqrt((a1-b1)*(a1-b1)+(a2-b2)*(a2-b2));
A=acos((b*b+c*c-a*a)/(2*b*c))*180/3.14159265;
B=acos((a*a+c*c-b*b)/(2*a*c))*180/3.14159265;
C=acos((a*a+b*b-c*c)/(2*a*b))*180/3.14159265;
printf("A=%lf\nB=%lf\nC=%lf\n",A,B,C);
printf("a=%lf\nb=%lf\nc=%lf\n",a,b,c);
}