| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
为什么WA啊 !哪位高手能告诉我#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator