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 |
为什么我area/4才对????????#include<cstdio> #include<cstring> #include<string> #include<cmath> #include<algorithm> #include<iostream> #define INF 0x7fffffff #define eps 1e-8 #define manx 1000005 typedef long long LL; using namespace std; char step[manx]; double xo,yo; struct Point{ double x,y; }; double Multi(Point p1,Point p2) { return (p2.x*p1.y)-(p1.x*p2.y); } void Move(char ch) { switch(ch) { case '8':{yo+=1;break;} case '2':{yo-=1;break;} case '6':{xo+=1;break;} case '4':{xo-=1;break;} case '9':{xo+=1;yo+=1;break;} case '7':{xo-=1;yo+=1;break;} case '3':{xo+=1;yo-=1;break;} case '1':{xo-=1;yo-=1;break;} case '5':{xo=0;yo=0;break;} } } int main() { int T,i; char ch1,ch2; scanf("%d",&T); getchar(); while(T--) { double sum=0.0; xo=0.0,yo=0.0; gets(step); for(i=0;step[i]!='5';i++) { Point a,b; Move(step[i]); a.x=xo; a.y=yo; Move(step[i+1]); b.x=xo; b.y=yo; if(step[i+1]=='5') break; sum+=Multi(a,b); } sum=fabs(sum)/4;//求解为什么。。。。。 if(sum-floor(sum)<eps) printf("%.f\n",sum); else printf("%.1f\n",sum); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator