标签:
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 28332 Accepted Submission(s): 14528
只要记住这个公式:
如果逆时针给出点坐标,值为正,
如果顺时针给出点坐标,值为负。
当i=n-1 i+1就是n所代表的点就是第一个点。
#include<queue> #include<math.h> #include<stdio.h> #include<string.h> #include<string> #include<iostream> #include<algorithm> using namespace std; #define N 1234567 #define M 12 double x[N]; double y[N]; int main() { int n; while(cin>>n && n) { double sum = 0; for(int i = 1; i <= n; i++) { scanf("%lf %lf",&x[i], &y[i]); } for(int i = 1; i <= n-1; i++) { sum += (x[i]*y[i+1] - x[i+1]*y[i]); } sum += (x[n]*y[1] - x[1]*y[n]); printf("%.1f\n",0.5 * sum); } return 0; }
标签:
原文地址:http://www.cnblogs.com/wmxl/p/5351833.html