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

WA啊,哪位好心的大哥能指点一下啊!万分感谢!

Posted by jiabiao at 2006-04-18 14:01:41 on Problem 1657
#include<stdio.h>
#include<math.h>
void wang(int m1,int n1,int m2,int n2)
{
   int count1,count2;
   if(m1==m2&&n1!=n2)
   printf("%d ",abs(n1-n2));
   if(n1==n2&&m1!=m2)
   printf("%d ",abs(m1-m2));
   if(m1!=m2&&n1!=n2)
   {
      count1=abs(m1-m2);
      count2=abs(n1-n2);
      if(count1<count2)
      printf("%d ",count2);
      if(count2<=count1)
      printf("%d ",count1);
   }
}
void hou(int m1,int n1,int m2,int n2)
{
   if(m1==m2||n1==n2)
   printf("1 ");
   if(abs(m1-m2)==abs(n1-n2))
   printf("1 ");
   if(m1!=m2&&n1!=n2&&abs(m1-m2)!=abs(n1-n2))
   printf("2 ");
}
void che(int m1,int n1,int m2,int n2)
{
   if(m1==m2||n1==n2)
   printf("1 ");
   else
   printf("2 ");
}
void xiang(int m1,int n1,int m2,int n2)
{
   if(abs(m1-m2)==abs(n1-n2))
   printf("1\n");
   else
   printf("Inf\n");
}
int main()
{
   char a[5];
   int T,i;
   int m1,m2,n1,n2;
   scanf("%d",&T);
   getchar();
   for(i=0;i<T;i++)
   {
      gets(a);
      n1='h'-a[0]+0;
      m1=a[1]-48-1;
      n2='h'-a[3]+0;
      m2=a[4]-48-1;
      puts(a);
      printf("%d %d %d %d\n",m1,n1,m2,n2);
      if(m1==m2&&n1==n2)
	  {
         printf("0 0 0 0\n");
		 continue;
	  }
      wang(m1,n1,m2,n2);
      hou(m1,n1,m2,n2);
      che(m1,n1,m2,n2);
      xiang(m1,n1,m2,n2);
   }
   return 0;
}

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