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> #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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator