| ||||||||||
| 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 | |||||||||
Re:偶人品值不低,智慧也还可以,WHY-----不服In Reply To:偶人品值不低,智慧也还可以,WHY-----不服 Posted by:00448224 at 2005-03-11 09:53:43 > #include<iostream.h>
> #include<math.h>
> void main()
> {
> int n,k,q,r,e;
> char ch1[2],ch2[2];
> cin>>n;
> for(int i=1;i<=n;i++)
> {
> cin>>ch1>>ch2;
>
> //王 等于差的绝对值中较大的一个
> k=(abs(ch1[0]-ch2[0])>abs(ch1[1]-ch2[1])?abs(ch1[0]-ch2[0]):abs(ch1[1]-ch2[1]));
> //后 等于1或2
> if((ch1[0]==ch2[0])||(ch1[1]==ch2[1])||(abs(ch1[0]-ch2[0])==abs(ch1[1]-ch2[1])))
> q=1;
> else
> q=2;
> //车 等于1或2
> if((ch1[0]==ch2[0])||ch1[1]==ch2[1])
> r=1;
> else
> r=2;
> //象 处于正方形对角线上时为1
> if(abs(ch1[0]-ch2[0])==abs(ch1[1]-ch2[1]))
> e=1;
> else
> {
> int m=abs(ch1[0]-ch2[0])+abs(ch1[1]-ch2[1]);
> 差的绝对值之和为偶数时等于2,为奇数时不能到达
> if(m%2==0)
> e=2;
> else
> e=0;
> }
> //输出结果
> if(e)
> cout<<k<<" "<<q<<" "<<r<<" "<<e<<endl;
> else
> cout<<k<<" "<<q<<" "<<r<<" "<<"Inf"<<endl;
> }
> }
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator