| ||||||||||
| 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>
int i,j;
int x1[2],y1[2],x2[2],y2[2],A[2],B[2],C[2];
int main()
{
int n;
scanf("%d",&n);
puts("INTERSECTING LINES OUTPUT");
while(n--)
{
for(i=0;i<2;i++)
{
scanf("%d%d%d%d",(x1+i),(y1+i),(x2+i),(y2+i));
A[i]=y2[i]-y1[i];
B[i]=x1[i]-x2[i];
C[i]=y1[i]*(x2[i]-x1[i])-x1[i]*(y2[i]-y1[i]);
}
if(A[1]*B[0]==A[0]*B[1])
{
if(A[1]*C[0]==A[0]*C[1])
puts("LINE");
else
puts("NONE");
}
else
{
double a,b;
a=(double)( B[1]*C[0]-B[0]*C[1] )/( A[1]*B[0]-A[0]*B[1] );
b=(double)( A[1]*C[0]-A[0]*C[1] )/( B[1]*A[0]-B[0]*A[1] );
printf("POINT %.2f %.2f\n",a,b);
}
}
puts("END OF OUTPUT");
// while(getchar()!=EOF);
return 0;
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator