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 crazypapa at 2012-09-05 19:13:02 on Problem 1657
#include <stdio.h>
#include <string.h>
#include <math.h>

int main()
{
	int cases=0;
	int n1=0;
	char inf[4]={'\0'};
	int king=0;//王所需要走的步数
	int queen=0;
	int car=0;
	int elephant=0;
	int dx=0,dy=0;

	scanf("%d",&cases);
	getchar();
	for(;n1<cases;n1++)
	{
		scanf("%c%c %c%c",inf,inf+1,inf+2,inf+3);
		getchar();
		/*
		putchar(inf[0]);
		putchar(inf[1]);
		putchar(inf[2]);
		putchar(inf[3]);
		*/
		dx=abs(inf[2]-inf[0]);
		dy=abs(inf[3]-inf[1]);

		if((dx==0)&&(dy==0))
		{
			printf("0 0 0 0\n");
			continue;
		}//起始位置跟终止位置相同的情况
		//王
		king= (dx>dy)?dx:dy;
		//王后
		if((dx==dy)||(dx==0)||(dy==0))
		{
			queen=1;
		}
		else queen=2;
		//车
		if((dx==0)||(dy==0))
		{
			car=1;
		}
		else 
		{
			car=2;
		}

		printf("%d %d %d ",king,queen,car);
		//象
		if(abs(dx-dy)%2!=0)
		{
			printf("Inf\n");
		}
		else if(dx==dy)
		{
			printf("1\n");
		}
		else
		{
			printf("2\n");
		}
	}
	return 0;

}
注意两点 首先是象能走全部的黑格  白格不能走
然后 在相同的位置的时候 应该输出0 0 0 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