Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

我用的也是经典的求面积的方法,可是怎么会错呢 还请高人指点一二

Posted by bingbing at 2009-02-15 10:22:14 on Problem 1654
#include <iostream>
#include <cmath>

using namespace std ;

struct Point
{
    __int64 x ;
    __int64 y ;
};

char step ;
Point next ;
__int64 area ;

void solve()
{
    Point tmp = next ;

    switch(step)
    {
    case'1': next.x += -1 ; next.y += -1 ; break ;
    case'2': next.y += -1 ; break ;
    case'3': next.x += 1 ; next.y += -1 ; break ;
    case'4': next.x += -1 ; break ;
    case'6': next.x += 1 ; break ;
    case'7': next.x += -1 ; next.y += 1 ; break ;
    case'8': next.y += 1 ; break ;
    case'9': next.x += 1 ; next.y += 1 ; break ;
    }

    area += tmp.x*next.y-next.x*tmp.y ;

}

int main()
{
    int n ;

    cin >> n ;

    while( n-- )
    {
        next.x = next.y = 0 ;
        area = 0 ;
        while( cin >> step )
        {
            if(step=='5')
            {
                break ;
            }
            solve() ;
        }
        cout << abs(area/2.0) << endl ;
    }
    return 0 ;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator