hdoj-2036-reform Spring breeze blowing the ground to find the polygon area

Source: Internet
Author: User

Reform Spring breeze blowing everywhereTime limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)
Total submission (s): 22754 Accepted Submission (s): 11772


Problem Description "Reform spring breeze blowing 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 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 n vertices given in counter-clockwise 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, print the corresponding polygon area, and the result is exactly one decimal after the decimal point.
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

Authorlcy
SOURCEACM Program Design Final Exam (2006/06/07)
Recommendlcy | We have carefully selected several similar problems for you:1115 1086 2108 2037 1392
#include <stdio.h> #include <math.h>struct point{   double x, y;} P[110];d ouble Cross (point A,point b) {return (a.x*b.y-a.y*b.x)/2.0;} int main () {int n;while (scanf ("%d", &n), N) {for (int i=0;i<n;++i) {scanf ("%lf%lf", &P[I].X,&P[I].Y);} Double res=0;for (int i=1;i<=n;++i) {Res+=cross (p[i%n],p[i-1]);} printf ("%.1lf\n", Fabs (res));} return 0;}


Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

hdoj-2036-reform Spring breeze blowing the ground to find the polygon area

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.