1186:0 starting point Learning algorithm 93--reform Spring Breeze blowing Montreal time limit:1 Sec Memory limit:32 MB 64bit IO Format:%lld
submitted:876 accepted:367
[Submit] [Status] [Web Board] Description
"The Spring breeze blows everywhere,
no AC okay;
I really can't go back to my hometown
There is another acre of land.
Thank you! (band playing) "
Saying that some students are very good mentality, every day to know the game, the exam is so simple topic, but also foggy, but also to such a few limerick.
Well, the teacher's responsibility is to help you solve the problem, since you want to farm, it will be a piece of you.
This field is located in Wenzhou Cangnan County, Zhejiang Province Ling Xi Zhen Forest Home Shop village, polygon shape of a piece of land, originally Linle, now ready to give you. However, nothing is so simple, you must first tell me how much area the land is, and if the answer is correct, you can really get the land.
Are you worried? is to let you know, the farming also needs AC knowledge! After the good practice it ...
Input
The input data contains multiple test instances, one row per test instance, and the beginning of each line is an integer n (3<=n<=100), which represents the number of sides of the polygon (and, of course, the number of vertices), followed by the coordinates of the n vertices given in a counterclockwise order (x1, y1, x2, y2 ... xn, Yn), in order to simplify the problem, all coordinates here are represented by integers.
All integers in the input data are within a 32-bit integer range, and n=0 represents the end of the data and does not handle it.
Output
For each test instance, output the corresponding polygon area, and the result is exactly one decimal point after the decimal.
The output for each instance takes up one row.
Sample Input
3 0 0 1 0 0 14 1 0 0 1-1 0 0-10
Sample Output
0.52.0
Source
0 Starting point Learning algorithm
The code is as follows:
#include <stdio.h>int main () { int n, i; Double a[102][2]; while (scanf ("%d", &n)! = EOF && n! = 0) { for (i = 0; i < n; i++) scanf ("%lf%lf", &a[i][0], &am P;A[I][1]); A[n][0] = a[0][0]; A[N][1] = a[0][1]; Double sum = 0; for (i = 0; i < n; i++) sum + = (a[i][0] * a[i+1][1]-a[i+1][0] * a[i][1]); sum = SUM/2; printf ("%.1lf\n", sum); } return 0;}
Wust Online Judge-1186:0 start-up algorithm 93--reform Spring breeze blowing everywhere