• <input id="auww4"></input>
  • <input id="auww4"><acronym id="auww4"></acronym></input>
  • <input id="auww4"><u id="auww4"></u></input>
    <object id="auww4"><acronym id="auww4"></acronym></object>
    <menu id="auww4"></menu><input id="auww4"><u id="auww4"></u></input>
    <input id="auww4"><u id="auww4"></u></input>
  • F.A.Q
    Hand In Hand
    Online Acmers
    Forum | Discuss
    Statistical Charts
    Problem Archive
    Realtime Judge Status
    Authors Ranklist
     
         C/C++/Java Exams     
    ACM Steps
    Go to Job
    Contest LiveCast
    ICPC@China
    Best Coder beta
    VIP | STD Contests
    Virtual Contests
        DIY | Web-DIY beta
    Recent Contests
    Author ID 
    Password 
     Register new ID

    One Tapc->->e

    Posted by TZ at 2020-12-13 22:19:25 on Problem 2036
    (8)  


    #include <iostream>
    #include <math.h>
    struct point
    {
    	int x;
    	int y; 
    };
    
    // Ӌe 
    double area(point a,point b)
    {
    	return a.x*b.y-a.y*b.x;
    } 
    
    int main() 
    {
    	int n;
    	double sum;
    	while(scanf("%d",&n)!=EOF)
    	{
    		sum=0.0;
    		if(n==0)
    		{
    			break;
    		}
    		point a[100];
    		
    		//ݔ 
    		for(int i=0;i<n;i++)
    		{	
    			scanf("%d%d",&a[i].x,&a[i].y);
    		}
    		
    		//ԵһcλԴcÿһcxyDcһc 
    		for(int j=1;j<n;j++)
    		{
    			a[j].x-=a[0].x;
    			a[j].y-=a[0].y;
    		}
    		
    		//Ƀe 
    		for(int i=1;i+1<n;i++)
    		{
    			sum+=area(a[i],a[i+1]);
    		}
    		
    		//ӛòeƽ߅ eҪԶ 
    		printf("%.1f\n",sum/2);
    	}
    	 
    	return 0;
    }

    Followed by:


    Post your reply here:

    Author ID
    Password
    Title
    Content  
     
    Hangzhou Dianzi University Online Judge 3.0
    Copyright © 2005-2021 HDU ACM Team. All Rights Reserved.
    Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
    Total 0.015600(s) query 5, Server time : 2021-01-21 09:36:50, Gzip enabled