Triangle Area time limit:MS | Memory limit:65535 KB Difficulty:2
-
Describe
-
give you three points, representing the three vertices of a triangle, now your task is to find out the area of the triangle.
-
-
Input
-
-
each row is a set of test data, with 6 integer x1,y1,x2,y2,x3,y3 representing the horizontal ordinate of three points, respectively. (Coordinate values from 0 to 10000)
Input 0 0 0 0 0 0 indicates end of input
No more than 10000 test data sets
-
-
Output
-
-
outputs the area of the triangle represented by these three points, resulting in a precision of 1 digits after the decimal point (even if an integer is a
decimal digit)
-
-
Sample input
-
-
0 0 1 1 1 30 1 1 0 0 00 0 0 0 0 0
-
-
Sample output
-
-
1.00.5
-
-
Source
-
-
Computational Geometry Basics
-
-
Uploaded by
-
-
Zhang Yunzun
-
-
mainly in the area of the Triangle formula set three vertices for O a B is the area of OA fork by the OB,
-
-
xi=x1-x3;
Yi=y1-y3;
xj=x2-x3;
Yj=y2-y3;
-
-
| Xi Yi |
-
-
-
| XJ YJ |
-
-
-
-
-
s== (*|) (Xi*yj-xj*yi) | ((Xi*yj-xj*yi) to seek absolute value)
-
-
-
#include <stdio.h> #include <math.h> #define LL long Longint main () {int x1,x2,x3,y1,y2,y3;double sum;double Xi,yi,xj,yj;while (scanf ("%d%d%d%d%d%d", &x1,&y1,&x2,&y2,&x3,&y3)) {if (x1==0&&y1= =0&&x2==0&&y2==0&&x3==0&&y3==0) break;xi=x1-x3;yi=y1-y3;xj=x2-x3;yj=y2-y3;sum= Fabs (XI*YJ-YI*XJ)/2.0;printf ("%.1lf\n", Sum);}}
-
Nyoj 673 Angular area "Triangle area Formula"