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

1654自测正确,提交waT_T!!求指正!!!

Posted by acm2013acm at 2013-11-27 13:03:09
#include<stdio.h>
#include<math.h>
#define N 20
char p[1000000];
int main()
{
	double area[N];
	int num,i,x,y,lastx,lasty;
	char *path;
	scanf("%d",&num);
	for(i=0;i<num;i++)
	{
		path=p;
		x=0;y=0;lastx=0;lasty=0;
		area[i]=0;
		scanf("%s",path);
		while(*path!='5')
		{
			switch(*path)
			{
				case '8':y++;break;
				case '6':x++;break;
				case '4':x--;break;
				case '2':y--;break;
				case '7':x--;y++;break;
				case '9':x++;y++;break;
				case '3':x++;y--;break;
				case '1':x--;y--;break;
			}
			area[i]+=abs(lastx*y-x*lasty)/2.0;
			lastx=x;lasty=y;
			path++;	
		}
	}
	for(i=0;i<num;i++)
    {
        if(area[i]!=(int)area[i])
            printf("%.1lf\n",area[i]);
        else
            printf("%.0lf\n",area[i]);
    }
	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