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

Re:高手们帮我看看到底那儿错了,谢谢:)

Posted by smark at 2007-03-03 20:29:23 on Problem 1657
In Reply To:高手们帮我看看到底那儿错了,谢谢:) Posted by:huhu at 2006-02-23 15:49:08
> #include<iostream.h>
> void main(){
> 	int x,a,b,A1,A2,wang,hou,che;
> 	char c,d,xiang;
> 	cin>>x;
> 	for(int i=0;i<x;i++){
> 		cin>>c>>a>>d>>b;
> 		if((a>8||a<0)||(b>8||b<0)||(c>'h')||(d>'h'))break;
> 		if(a==b&&c==d)    
> 			cout<<"0 0 0 0"<<endl;
> 		if (a>b||a==b) A1=a-b;
> 		else A1=b-a;
> 		if(c>d||c==d) A2=c-d;
> 		else A2=d-c;
> 		if (A1>A2||A1==A2) wang=A1;
> 		else int wang=A2;
> 		if(A1==0||A2==0||A1==A2) hou=1;
> 		else  hou=2;
> 		if(A1==0||A2==0) che=1;
> 		else che=2;
> 		if((A1-A2)%2==0){
> 			if(A1-A2==0)xiang='1';
> 			else xiang='2';
> 			cout<<wang<<" "<<hou<<" "<<che<<" "<<xiang<<endl;
> 		}
> 		else cout<<wang<<" "<<hou<<" "<<che<<" Inf"<<endl;
> 	}
> }
> 
> 
> 如果是相同位置,结果会有错的.上code中if(a==b&&c==d)  cout<<"0 0 0 0"<<endl; 运行后,下面的code还会运行的!

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