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> int main() { int t,i,l1,l2,s1,s2,s3; char a[5],b[5]; scanf("%d",&t); for(i=0;i<t;i++) { scanf("%s%s",&a,&b); l1=a[0]>b[0]?a[0]-b[0]:b[0]-a[0]; l2=a[1]>b[1]?a[1]-b[1]:b[1]-a[1]; s1=l1>l2?l1:l2; if(l1==0&&l2==0) { printf("0 0 0 0\n");continue;} else if(l1==0||l2==0) s2=s3=1; else { s2=1;s3=2;} printf("%d %d %d ",s1,s2,s3); if(l1==l2) printf("1\n"); else if(l1%2==l2%2) printf("2\n"); else printf("Inf\n"); } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator