The problem is described as a point in two-dimensional space design a structure, on the basis of which a structure for the triangle design. Separate functions are designed to calculate the perimeter, area, center, and centroid of the triangle. Enter three points to output the perimeter, area, Circumcenter, and center of gravity of the triangles that comprise these three points. The result retains 2 digits after the decimal point. The output of the sample output corresponds to the example input above.
Cases:
Data size and convention the range of each number in the input data.
Example: Doule type represents data.
1#include <bits/stdc++.h>2 using namespacestd;3 intMain ()4 {5 DoubleX1,y1,x2,y2,x3,y3;6 Doublea,b,c,p;7 Doubleaa,bb,zz,aa1,bb1,zz1;8scanf"%LF%LF",&x1,&y1);9scanf"%LF%LF",&x2,&y2);Tenscanf"%LF%LF",&x3,&y3); OneA=sqrt ((x1-x2) * (X1-X2) + (y1-y2) * (y1-y2)); AB=sqrt ((x1-x3) * (X1-X3) + (y1-y3) * (y1-y3)); -C=sqrt ((x3-x2) * (X3-X2) + (y3-y2) * (y3-y2)); -printf"%.2lf\n", a+b+c);//Perimeter thep= (A+B+C)/2.0; -printf"%.2lf\n", sqrt (p* (p-a) * (p-b) * (P-C)));//Area -Aa=2* (x1-x2); -bb=2* (y1-y2); +zz=x1*x1-x2*x2+y1*y1-y2*Y2; -cas=2* (x3-x2); +bb1=2* (y3-y2); Azz1=x3*x3-x2*x2+y3*y3-y2*Y2; atprintf"%.2LF%.2lf\n", ((ZZ*BB1)-(ZZ1*BB))/((AA*BB1)-(aa1*BB)), -((AA*ZZ1)-(AA1*ZZ))/((AA*BB1)-(AA1*BB)));//Circumcenter -printf"%.2LF%.2lf\n", (X1+X2+X3)/3.0, (Y1+Y2+Y3)/3.0);//Center of Gravity - return 0; -}
Algorithm improves 12-1 triangular circumcenter coordinates