[c++]代码库
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
int n;
char star[3], end[3];
cin >> n;
for(int i = 0; i < n; i++)
{
cin >> star >> end;
int x=abs(star[0]-end[0]);
int y=abs(star[1]-end[1]);
if(x==0&&y==0)//不动的情况
cout << 0 << " "<< 0 << " "<< 0 << " "<< 0 << endl;
else
{
if(x > y) //王行走
cout << x << " ";
else
cout << y << " ";
if(x==0||y==0||x==y)//后行走
cout << 1 << " ";
else
cout << 2 << " ";
if(x==0||y==0)//车行走
cout << 1 << " ";
else
cout << 2 << " ";
if(abs(x-y)%2 != 0)//象行走
cout << "Inf" << endl;
else
if(x==y)
cout << 1 << endl;
else
cout << 2 << endl;
}
}
return 0;
}
高级设计师
by: 小蜜锋 发表于:2014-05-27 20:10:19 顶(0) | 踩(0) 回复
原题是怎样的?
回复评论