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 |
wa的没信心了,大家帮忙看下……#include <stdio.h> #include <iostream.h> int t,tt; char b[50],a[50]; int i,x,y,xx,yy,j,p=0; int area; float area2; __int64 init; void main() { scanf("%d",&tt); for(t=0;t<tt;t++) { scanf("%I64d",&init); i=0; while(init>0) { b[i]=init%10; init=init/10; i++; } for(j=0;j<i;j++) { a[j]=b[i-j-1]; } x=0,y=0; j=0; area=0; while(1) { if(a[j]==5) break; else if(a[j]==8) {xx=x; yy=y+1;} else if(a[j]==2) {xx=x; yy=y-1;} else if(a[j]==6) {xx=x+1; yy=y;} else if(a[j]==4) {xx=x-1; yy=y;} else if(a[j]==9) {xx=x+1; yy=y+1;} else if(a[j]==7) {xx=x-1; yy=y+1;} else if(a[j]==3) {xx=x+1; yy=y-1;} else if(a[j]==1) {xx=x-1; yy=y-1;} else break; j++; area=area+x*yy-xx*y; x=xx,y=yy; } if(area<0) area=area*(-1); area2=(float)area/2; if(area2==(float)((int)(area/2))) printf("%.0f\n",area2); else printf("%.1f\n",area2); } } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator