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 cpp050800448280 at 2005-03-20 11:18:28 on Problem 1654
#include<stdio.h>
#include<iostream.h>
#include<math.h>

void main()
{
	int time;
	cin>>time;
	__int64 result[99];
	char a;
	int x=0;
	int y=0;
	int j=0;
	int dx=0;
	int dy=0;
	__int64 area1=0;
	for(int i=0;i<time;i++)
	{
		while(1)
		{
			
			cin>>a;
			if(a=='5') break;
			switch(a)
			{
				case'9':dx=1;  dy=1;break;
				case'6':dx=1;  dy=0;break;
				case'3':dx=1; dy=-1;break;
				case'2':dx=0; dy=-1;break;
				case'1':dx=-1;dy=-1;break;
				case'4':dx=-1; dy=0;break;
				case'7':dx=-1; dy=1;break;
				case'8':dy=1;  dx=0;break;
				case'5':break;
				default:break;
			}
			area1 += x*(y+dy)-y*(x+dx);
			x=x+dx;
			y=y+dy;
		}
			if((x==0)&&(y==0))
			{
				result[i]=((area1>0) ? area1:-1*area1);
				area1=0;
				x=0,dx=0;
				y=0,dy=0;
			}
			else
			{
				result[i]=0;
				area1=0;
				x=0,dx=0;
				y=0,dy=0;
			}
		
	}
	for(int p=0;p<time;p++)
	{
		if(result[p]%2)
		{
			printf("%d",result[p]/2);
			cout<<".5"<<endl;
		}
		else
			printf("%d\n",result[p]/2);			

	}
}


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