Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

发一个短一些的代码

Posted by libojie at 2009-02-21 20:58:38 on Problem 1657
主要是注意逻辑顺序,不要遗漏情况。
代码仅供参考,请勿抄袭。
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator