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 00704099 at 2008-10-02 23:51:37 on Problem 3668
下面程序觉着没什么问题,可就是通不过,郁闷啊!
#include<stdio.h>
#include<malloc.h>
struct line
{
	int line_x,line_y;
	int tag;
};
int main()
{
	int i,j,l=0,*x,*y,line_num,point_num;
	struct line *lline;
	scanf("%d",&point_num);
	x=(int*)malloc(sizeof(int)*point_num);
	y=(int*)malloc(sizeof(int)*point_num);
	for(i=0;i<point_num;i++)
	scanf("%d%d",x+i,y+i);
	line_num=point_num*(point_num-1)/2;
	lline=(struct line*)malloc(sizeof(struct line)*line_num);
	for(i=0;i<point_num-1;i++)
		for(j=i+1;j<point_num;j++)
		{
			lline[l].line_x=x[j]-x[i];
			lline[l].line_y=y[j]-y[i];
			lline[l].tag=1;
			l++;
		}
		l=line_num;
			for(i=0;i<line_num-1&&lline[i].tag;i++)
				for(j=i+1;j<line_num&&lline[j].tag;j++)
					if(lline[i].line_x*lline[j].line_y==lline[j].line_x*lline[i].line_y)
					{
						lline[j].tag=0;
						l--;
					}
     printf("%d",l);
	 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