| ||||||||||
| 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 | |||||||||
初始化没有每次都初始化;王的走法判断不对In Reply To:有没有大侠知道我的程序错在哪里!!! Posted by:hustzh at 2009-02-20 19:58:57 #include <iostream>
#include <string>
#include <math.h>
using namespace std;
int main()
{
short n;
cin >> n;
string s1,s2;
char x1,y1,x2,y2;
for(int i = 0;i < n;i++)
{
short a,b = 2,c = 2,d = 2; // 应该在这里初始化,每循环一次都初始化
cin >> s1 >> s2;
x1 = s1[0]; y1 = s1[1];
x2 = s2[0]; y2 = s2[1];
if(x1 == x2 && y1 == y2)
cout << "0 0 0 0" << endl;
else
{
if (abs(x1-x2) > abs(y1-y2))
{
a = abs(x1-x2);
}
else
{
a = abs(y1-y2);
}
if(x1 == x2 || y1 == y2 || (abs(x1-x2) == abs(y1-y2)))
b = 1;
if(x1 == x2 || y1 == y2)
c = 1;
cout << a << " " << b << " " << c << " ";
if(abs(x1-x2)%2 != abs(y1-y2)%2)
cout << "Inf" << endl;
else
{
if(abs(x1-x2) == abs(y1-y2))
d = 1;
cout << d << endl;
}
}
}
return 0;
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator