标签:
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 24179 Accepted Submission(s): 12504
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)) 25 using namespace std; 26 const int dx4[4]={1,0,0,-1}; 27 const int dy4[4]={0,-1,1,0}; 28 typedef long long LL; 29 #define sec second 30 const int inf = 0x3f3f3f3f; 31 const int N=105; 32 int n; 33 struct point 34 { 35 double x,y; 36 point(){} 37 point(double _x,double _y): 38 x(_x),y(-y){}; 39 void input() 40 { 41 scanf("%lf%lf",&x,&y); 42 } 43 double det(point p) 44 { 45 return x*p.y-y*p.x; 46 } 47 }; 48 struct polygon 49 { 50 point p[N]; 51 void input() 52 { 53 for ( int i = 0 ; i < n ; i++) 54 { 55 p[i].input(); 56 } 57 } 58 double getarea() 59 { 60 double sum= 0 ; 61 int i; 62 for ( int i = 0 ; i < n ; i++ ) 63 { 64 sum+=p[i].det(p[(i+1)%n]); 65 } 66 return fabs(sum)/2; 67 } 68 }pol; 69 int main() 70 { 71 #ifndef ONLINE_JUDGE 72 freopen("in.txt","r",stdin); 73 #endif 74 while (scanf("%d",&n)!=EOF&&n) 75 { 76 pol.input(); 77 printf("%.1f\n",pol.getarea()); 78 } 79 80 81 82 #ifndef ONLINE_JUDGE 83 fclose(stdin); 84 #endif 85 return 0; 86 }
标签:
原文地址:http://www.cnblogs.com/111qqz/p/4942357.html