Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
我用的也是经典的求面积的方法,可是怎么会错呢 还请高人指点一二#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator