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

错在哪里呢?总是wrong answer.哪位好心指点?

Posted by BABYBLUE at 2005-02-28 21:29:08 on Problem 1657
#include<iostream.h>
#include<math.h>
void wang(char a,char b,char c,char d){
	int g;
	int i=a-c;
	int j=b-d;
	
	if((int)fabs(i)>(int)fabs(j))
	   g=(int)fabs(i);
	
	else
      g=(int)fabs(j);

	cout<<g<<" ";
}
void hou(char a,char b,char c,char d){
    int i=a-c;
	int j=b-d;
    int k=(int)fabs(i)-(int)fabs(j);
	if(k==0||i==0||j==0)
		cout<<"1 ";
	else 
		cout<<"2 ";
}
void che(char a,char b,char c,char d){
    int i=a-c;
	int j=b-d;
    if(i==0||j==0)
		cout<<"1 ";
	else
		cout<<"2 ";
}
void xiang(char a,char b,char c,char d){
    int i=a-c;
	int j=b-d;
	if((i%2)!=(j%2))
		cout<<"Inf\n";
	else if((int)fabs(i)==(int)fabs(j))
		cout<<"1\n";
	else
		cout<<"2\n";
}
void play(){
    char start[2];
	char end[2];
	char a,b,c,d;
	cin>>start;
    cin>>end;
	a=start[0];
	b=start[1];
	c=end[0];
	d=end[1];
	if(a>'g'||a<'a'||c>'g'||c<'a'||b>8||b<1||d>8||d<1)
		return;
	if(a==c&&b==d){
	cout<<"0 0 0 0\n";
	return;
	}
	wang(a,b,c,d);
    hou(a,b,c,d);
    che(a,b,c,d);
    xiang(a,b,c,d);
}
void main(){
	int num,p=1;
    
    cin>>num;
	if(num<0||num>20)
		return;
	while(p<=num)
	{  play();
	   p++;}
}

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