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 |
我的程序的怪事,求指导#include<stdio.h> #include<stdlib.h> int main() {int i,t,Xx,Xy,Yx,Yy; char Xchar,Ychar; scanf("%d",&t); for(i=1;i<=t;i++) {scanf("%c%d %c%d",&Xchar,&Xy,&Ychar,&Yy); Xx='i'-Xchar; Yx='i'-Ychar; if ((Xx==Yx)&&(Xy==Yy)) {printf("0 0 0 0\n");} else { int absx=abs(Xx-Yx); int absy=abs(Xy-Yy); //王的步数 if (absx>absy) {printf("%d ",absx);} else {printf("%d ",absy);} //后的步数 if ( (Xx==Yx)||(Xy==Yy)||(absx==absy) ) {printf("1 ");} else {printf("2 ");} //车的步数 if ((Xx==Yx)||(Xy==Yy)) {printf("1 ");} else {printf("2 ");} //象的步数 if ((Xx+Xy)%2!=(Yx+Yy)%2) {printf("Inf\n");} else {if (absx==absy) {printf("1\n");} else {printf("2\n");} } } } return 0; } 令我抓狂的是:我的程序输入样例后 My Input 2 a1 c3 f5 f8 My Output 79693342 2 2 2(不知道从哪里来的!!) 2 1 2 1(答案正确) 92 2 2 2(不知道从哪里来的!!! ) 3 1 1 Inf (答案正确) 请高手们指教一下 Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator