改革春风吹满地#
**Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 24179 Accepted Submission(s): 12504 **
Problem Description
" 改革春风吹满地, 不会AC没关系; 实在不行回老家, 还有一亩三分地。 谢谢!(乐队奏乐)"
话说部分学生心态极好,每天就知道游戏,这次考试如此简单的题目,也是云里雾里,而且,还竟然来这么几句打油诗。 好呀,老师的责任就是帮你解决问题,既然想种田,那就分你一块。 这块田位于浙江省温州市苍南县灵溪镇林家铺子村,多边形形状的一块地,原本是linle 的,现在就准备送给你了。不过,任何事情都没有那么简单,你必须首先告诉我这块地到底有多少面积,如果回答正确才能真正得到这块地。 发愁了吧?就是要让你知道,种地也是需要AC知识的!以后还是好好练吧…
Input
输入数据包含多个测试实例,每个测试实例占一行,每行的开始是一个整数n(3<=n<=100),它表示多边形的边数(当然也是顶点数),然后是按照逆时针顺序给出的n个顶点的坐标(x1, y1, x2, y2… xn, yn),为了简化问题,这里的所有坐标都用整数表示。 输入数据中所有的整数都在32位整数范围内,n=0表示数据的结束,不做处理。
Output
对于每个测试实例,请输出对应的多边形面积,结果精确到小数点后一位小数。 每个实例的输出占一行。
Sample Input
3 0 0 1 0 0 1 4 1 0 0 1 -1 0 0 -1 0
Sample Output
0.5 2.0
Author
lcy
Source
一个多边形。
n个定点按照逆时针方向给出..
求面积。
1/*************************************************************************
2> File Name: code/hdoj/2036.cpp
3> Author: 111qqz
4> Email: rkz2013@126.com
5> Created Time: 2015年11月06日 星期五 12时05分30秒
6************************************************************************/
7
8#include<iostream>
9#include<iomanip>
10#include<cstdio>
11#include<algorithm>
12#include<cmath>
13#include<cstring>
14#include<string>
15#include<map>
16#include<set>
17#include<queue>
18#include<vector>
19#include<stack>
20#include<cctype>
21#define fst first
22#define lson l,m,rt<<1
23#define rson m+1,r,rt<<1|1
24#define ms(a,x) memset(a,x,sizeof(a))
25using namespace std;
26const int dx4[4]={1,0,0,-1};
27const int dy4[4]={0,-1,1,0};
28typedef long long LL;
29#define sec second
30const int inf = 0x3f3f3f3f;
31const int N=105;
32int n;
33struct point
34{
35double x,y;
36point(){}
37point(double _x,double _y):
38x(_x),y(-y){};
39void input()
40{
41scanf("%lf%lf",&x;,&y);
42}
43double det(point p)
44{
45return x*p.y-y*p.x;
46}
47};
48struct polygon
49{
50point p[N];
51void input()
52{
53for ( int i = 0 ; i < n ; i++)
54{
55p[i].input();
56}
57}
58double getarea()
59{
60double sum= 0 ;
61int i;
62for ( int i = 0 ; i < n ; i++ )
63{
64sum+=p[i].det(p[(i+1)%n]);
65}
66return fabs(sum)/2;
67}
68}pol;
69int main()
70{
71#ifndef ONLINE_JUDGE
72freopen("in.txt","r",stdin);
73#endif
74while (scanf("%d",&n;)!=EOF&&n)
75{
76pol.input();
77printf("%.1fn",pol.getarea());
78}
79
80
81
82#ifndef ONLINE_JUDGE
83fclose(stdin);
84#endif
85return 0;
86}