标签:坐标 小数点 img 三角形 结构 三个点 code clu pac
1 #include<bits/stdc++.h> 2 using namespace std; 3 int main() 4 { 5 double x1,y1,x2,y2,x3,y3; 6 double a,b,c,p; 7 double aa,bb,zz,aa1,bb1,zz1; 8 scanf("%lf %lf",&x1,&y1); 9 scanf("%lf %lf",&x2,&y2); 10 scanf("%lf %lf",&x3,&y3); 11 a=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)); 12 b=sqrt((x1-x3)*(x1-x3)+(y1-y3)*(y1-y3)); 13 c=sqrt((x3-x2)*(x3-x2)+(y3-y2)*(y3-y2)); 14 printf("%.2lf\n",a+b+c);//周长 15 p=(a+b+c)/2.0; 16 printf("%.2lf\n",sqrt(p*(p-a)*(p-b)*(p-c)));//面积 17 aa=2*(x1-x2); 18 bb=2*(y1-y2); 19 zz=x1*x1-x2*x2+y1*y1-y2*y2; 20 aa1=2*(x3-x2); 21 bb1=2*(y3-y2); 22 zz1=x3*x3-x2*x2+y3*y3-y2*y2; 23 printf("%.2lf %.2lf\n",((zz*bb1)-(zz1*bb))/((aa*bb1)-(aa1*bb)), 24 ((aa*zz1)-(aa1*zz))/((aa*bb1)-(aa1*bb)));//外心 25 printf("%.2lf %.2lf\n",(x1+x2+x3)/3.0,(y1+y2+y3)/3.0);//重心 26 return 0; 27 }
标签:坐标 小数点 img 三角形 结构 三个点 code clu pac
原文地址:http://www.cnblogs.com/hsd-/p/6661668.html