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

求高人帮忙看一下--为什么GCC上运行不过,而TC上过,没越界!

Posted by 200628590 at 2007-05-09 15:25:45
#include"stdio.h"
#include"math.h"
int main()
{ int i,j,k,n,p,a[16],b[17];
  float max,y,w,s;
  char x[4],ch[16],c,d;
 while (scanf ("%d",&n)&&n!=0)
     {for (i=0;i<n;i++)
	  {scanf ("%c");
	   scanf ("%c%d%d",&ch[i],&a[i],&b[i]);
	  }
      max=0.5*((b[2]-b[0])*(a[1]-a[0])-(b[1]-b[0])*(a[2]-a[0]));
      for (i=0;i<n-2;i++)
	  for (j=i+1;j<n-1;j++)
	      for (k=j+1;k<n;k++)
		  {w=fabs(0.5*((b[k]-b[i])*(a[j]-a[i])-(b[j]-b[i])*(a[k]-a[i])));
		   if (max<w)
		     {y=0;
		      for (p=0;p<n;p++)
			  {if (p==i||p==j||p==k) ;
			  else
			   { s=fabs(0.5*((b[p]-b[i])*(a[j]-a[i])-(b[j]-b[i])*(a[p]-a[i])));
			     s=s+fabs(0.5*((b[p]-b[j])*(a[k]-a[j]) - (b[k] - b[j])*(a[p]-a[j])));
			     s=s+fabs(0.5*((b[p] - b[k])*(a[i] - a[k]) - (b[i] - b[k])*(a[p]-a[k])));
			  }
			   if (s==w)
			      y++;
			   }
		  if (y==0)
		     {max=w;
		      x[0]=ch[i];
		      x[1]=ch[j];
		      x[2]=ch[k];
		     }
		  }
	 }
    c=x[0];
    for (i=0;i<3;i++)
	for (j=i;j<3;j++)
	    if (c-x[j]>0)
	       { d=x[j];
		 x[j]=c;
		 c=d;
	       }
     x[0]=c;
    printf ("%c%c%c\n",x[0],x[1],x[2]);
 }
}

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