## 378 - Intersecting Lines

All about problems in Volume 3. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

Rafa3p
New poster
Posts: 5
Joined: Sun Dec 25, 2011 1:32 am

### Re: Problem 378

I changed this:

Code: Select all

``````            if(Y==0)printf("POINT %.2f 0.00\n",X);
else if(X==0) printf("POINT 0.00 %.2f\n",-Y);
else printf("POINT %.2f %.2f\n",X,-Y)
``````
for this:

Code: Select all

``````            if(X==0)printf("POINT 0.00");
else printf("POINT %.2f",X);
if(Y==0) printf(" 0.00\n");
else printf(" %.2f\n",-Y);
``````
And got AC.
I did this because sometimes i was printing "-0.00" instead of "0.00"

expecto_petronum
New poster
Posts: 2
Joined: Mon Oct 31, 2011 10:55 am

### UVA 378

Someone please help me with my code. Its got Wrong answer, i donot understand why?

Code: Select all

``````
#include<stdio.h>

int main()
{
printf("INTERSECTING LINES OUTPUT\n");
int n,x_1,x_2,x_3,x_4,y_1,y_2,y_3,y_4;
double d,d1,d2,t1,t2,x,y;

scanf("%d",&n);

while(n>0)
{
scanf("%d%d%d%d%d%d%d%d",&x_1,&y_1,&x_2,&y_2,&x_3,&y_3,&x_4,&y_4);
d=(double)((x_1-x_2)*(y_3-y_4))-((y_1-y_2)*(x_3-x_4));
d1=(double)((x_3-x_4)*(y_3-y_1))-((y_3-y_4)*(x_3-x_1));
d2=(double)(-((x_3-x_1)*(y_1-y_2))+((y_3-y_1)*(x_1-x_2)));

if((int)d==0 && (int)d1==0 && (int)d2==0)
{
printf("LINE\n");
}
else if((int)d==0)
{
printf("NONE\n");
}
else
{
t1=d1/d;
t2=d2/d;
x=x_1+t1*(x_2-x_1);
y=y_1+t1*(y_2-y_1);
printf("POINT %.2lf %.2lf\n",x,y);
}
n--;

}

printf("END OF OUTPUT");
return 0;
}

``````

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

### Re: UVA 378

Missing newline at end.
Check input and AC output for thousands of problems on uDebug!

samir_h
New poster
Posts: 11
Joined: Wed Mar 18, 2015 8:47 am

### [378 - Intersecting Lines][Wrong Answer] Please help

Problem: https://uva.onlinejudge.org/external/3/378.pdf
What is wrong with http://ideone.com/GvTfIo?
It solves mentioned input and https://www.udebug.com/UVa/378 random input.
But still getting WA after submit.