Problem description,
No AC;
I can't go back to my hometown,
There is also an acre of three sub-regions.
Thank you! (Band music )"
In other words, some students have a very good mentality and know about the game every day. The simple question of this test is also in the fog of the cloud. In addition, there are just a few poems.
Well, the teacher's responsibility is to help you solve the problem. If you want to farm your work, you can divide it into one.
This field is located in linjiabaozi village, lingxi town, Cangnan County, Wenzhou City, Zhejiang province, with a Polygon Shape. It was originally linle and is ready for you now. However, nothing is so simple. You must first tell me how much area the land actually has. If the answer is correct, you can really get the land.
Worried? It's just to let you know that it also requires AC knowledge to farm land! Try again later... input data contains multiple test instances. Each test instance occupies one row. Each row starts with an integer N (3 <=n <= 100 ), it represents the number of edges of a polygon (of course also the number of vertices), and then the coordinates of N vertices (x1, Y1, X2, y2... XN, yn). To simplify the problem, all coordinates here are represented by integers.
All the integers in the input data are within the 32-bit integer range. n = 0 indicates the end of the data and is not processed. For each test instance, output the corresponding polygon area. The result is precise to the decimal place.
The output of each instance occupies one row. Sample input3 0 0 1 0 14 1 0 1-1 0 0-10 sample output0.52.0
1 # include <stdio. h> 2 3 double get_area (double A, double B, double C, double D, double E, double F); 4 5 Int main () {6 int N; 7 Double X [101]; 8 Double Y [101]; 9 int I; 10 double total_area; 11 12 while (1) {13 scanf ("% d ", & N); 14 15 if (n = 0) 16 break; 17 18 total_area = 0; 19 for (I = 0; I <n; I ++) 20 scanf ("% lf", & X [I], & Y [I]); 21 22 for (I = 0; I <N-2; I ++) {// The default 0, 0 is the polygon vertices, calculate the area of The N-2 triangle and 23 total_area + = get_area (X [0], Y [0], X [I + 1], Y [I + 1], X [I + 2], Y [I + 2]); 24} 25 26 printf ("%. 1lf \ n ", total_area); 27} 28 29 return 0; 30} 31 32 double get_area (double A, double B, double C, double D, double E, double F) {// obtain the Area 33 double area using the known three-point coordinates; 34 35 area = (A * D + B * E + C * F-A * F-B * c-d * E)/2; // no absolute value 36 37 return area; 38}
Spring Breeze of Reform