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

为什么WA啊 !哪位高手能告诉我

Posted by shaohua2208 at 2008-12-01 21:58:14 on Problem 1657
#include <iostream>
#include <math.h>
using namespace std;

int main()
{
	char a[3];
	char b[3];
	int x1;
	int x2;
	int y1;
	int y2;
	int w;
	int h;
	int j;
	int x;
	int n;
	cin>>n;
	while(n){
		cin>>a>>b;
		x1 = a[0] - 96;
		x2 = b[0] - 96;
		y1 = a[1] - '0';
		y2 = b[1] - '0';
		if(x1 == x2 || y1 == y2){
			j = 1;
		}
		else
		{
			j = 2;
		}
		if(x1 == x2 || y1 == y2 || x2 - x1 == y2 - y1){
			h = 1;
		}
		else
		{
			h = 2;
		}
		if( x2 - x1 == y2 - y1 ){
			x = 1;
		}
		else if( (y1 - x1 ) % 2 == (y2 - x2) % 2){
			x = 2;
		}
		else 
		{
			x = 0;
		}
		if( x2 - x1 == y2 - y1 && ( x1 != x2 || y1 != y2)){
			w = abs(x2 - x1);
		}
		else if(x1 = x2 ){
			w = abs(y1 - y2);
		}
		else if(y1 = y2){
			w = abs(x1 - x2);
		}
		else if(abs(x1 - x2) > abs(y2 - y1)){
			w = abs(x2 - x1);
		}
		else {
			w = abs(y1 - y1) + abs(x2 - x1);
		}
		cout<<w<<" "<<h<<" "<<j<<" ";
		if(x == 0){
			cout<<"Inf"<<endl;
		}
		else 
		{
			cout<<x<<endl;
		}
		n--;
	}
	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