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 |
为什么总是WRONG ANSWER?在自己的机器上明明没问题的,郁闷!!HELP!!!#include <stdio.h> #include <math.h> int WANG(char a[2],char b[2]){ int x1,x2,y1,y2; int s; int u,v; x1=(int)a[0]; y1=(int)a[1]; x2=(int)b[0]; y2=(int)b[1]; u=abs(x1-x2); v=abs(y1-y2); if(u==0)s=v; else if(v==0)s=u; else if(u>v)s=u; else if(u<=v)s=v; return s; } int JU(char c[2],char d[2]){ int x1,x2,y1,y2; int s; x1=(int)c[0]; y1=(int)c[1]; x2=(int)d[0]; y2=(int)d[1]; if(x1==x2||y1==y2){ if(x1==x2&&y1==y2)s=0; else s=0; } else s=2; return s; } int HOU(char e[2],char f[2]){ int x1,x2,y1,y2; int s; x1=(int)e[0]; y1=(int)e[1]; x2=(int)f[0]; y2=(int)f[1]; if(x1==x2||y1==y2||(x1-x2)==(y1-y2)){ if(x1==x2&&y1==y2)s=0; else s=1; } else s=2; return s; } int XIANG(char m[2],char n[2]){ int x1,x2,y1,y2; int s; x1=(int)m[0]; y1=(int)m[1]; x2=(int)n[0]; y2=(int)n[1]; if((((x1-x2)%2==0)&&((y1-y2)%2!=0))||(((x1-x2)%2!=0)&&((y1-y2)%2==0)))s=-1; else{ if((x1-x2)==(y1-y2)){ if(x1==x2&&y1==y2)s=0; else s=1; } else s=2; } return s; } void main(){ int wang=0,hou=0,ju=0,xiang=0; char qidian[2],zhongdian[2]; int t,i; scanf("%d",&t); for(i=0;i<t;i++){ scanf("%s %s",qidian,zhongdian); wang=WANG(qidian,zhongdian); hou=HOU(qidian,zhongdian); ju=JU(qidian,zhongdian); xiang=XIANG(qidian,zhongdian); if(xiang!=-1)printf("%d %d %d %d\n",wang,hou,ju,xiang); else printf("%d %d %d Inf\n",wang,hou,ju); } } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator