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 <math.h> void distance(int x,int y,int a,int b) { int king,queen,knight, chancellor; king=x>y?y:x+(int)fabs(x-y); if(x==y||x==0||y==0) { queen=1; if(x==0||y==0) knight=1; else knight=2; } else queen=2; if((a%2==0&&b%2==0)||(a%2!=0&&b%2!=0)) { if(x==y) chancellor=1; else chancellor=2; } else chancellor=0; printf("%d %d %d ",king,queen,knight); if(chancellor==0) printf("Inf\n"); else printf("%d\n",chancellor); } int main() { int t,x,y,i,a,b; char spot1[5],spot2[5];//坑爹呀!!为毛把数组空间改为2就不能正常读入spot1的首位??? scanf("%d",&t); for(i=0;i<t;i++) { scanf("%s %s",spot1,spot2); x=fabs(spot1[0]-spot2[0]); y=fabs(spot1[1]-spot2[1]); a=fabs(spot1[0]-spot1[1]); b=fabs(spot2[0]-spot2[1]); if(x!=0||y!=0) //真心没有考虑到起始位置和末位置是同一个点 distance(x,y,a,b); else printf("0 0 0 0\n"); } system("pause"); } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator