2036改革春风吹满地

来源:互联网 发布:淘宝app地址管理在哪 编辑:程序博客网 时间:2024/04/27 05:17
//擦,我还改正负面积,反而错了,就要考虑正负
#include<stdio.h>#include<math.h>typedef struct p{int x,y;}p;double area(p a,p b,p c){    double t;    t=c.x*b.y+a.x*c.y+b.x*a.y-a.x*b.y-c.x*a.y-b.x*c.y;    t/=2.0;    return t;}int main(){    int t,i;    double s;    p pp[110];    while(scanf("%d",&t)!=EOF&&t!=0){        for(i=0;i<t;i++){            scanf("%d %d",&pp[i].x,&pp[i].y);        }        s=0;        for(i=2;i<t;i++){            s+=area(pp[i],pp[i-1],pp[0]);        }        printf("%.1lf\n",s);    }    return 0;}


原创粉丝点击