# Poj Solution 1269

```http://poj.org/problem?id=1269

//* @author popop0p0popo
import java.util.*;
import java.io.*;

public class Main{
public static void main(String[] args){
int n=scanner.nextInt();
double[] x,y;
double px,py;
double k1,k2,b1,b2;
System.out.println("INTERSECTING LINES OUTPUT");
for (int i=0;i< n ;i++ ){
x=new double;
y=new double;
for (int j=0;j< 4 ;j++ ){
x[j]=scanner.nextDouble();
y[j]=scanner.nextDouble();
}
if ((x-x)*(y-y)==(x-x)*(y-y)){
if ((x-x)*(y-y)==(x-x)*(y-y)){
System.out.println("LINE");
}
else{
System.out.println("NONE");
}
}
else{
if (x==x){
px=x;
k2=(y-y)/(x-x);
b2=y-k2*x;
py=k2*px+b2;
}
else if (x==x){
px=x;
k1=(y-y)/(x-x);
b1=y-k1*x;
py=k1*px+b1;
}
else{
k1=(y-y)/(x-x);
b1=y-k1*x;
k2=(y-y)/(x-x);
b2=y-k2*x;
px=(b2-b1)/(k1-k2);
py=k1*px+b1;
}
px=(Math.round(px*100.0))/100.0;
py=(Math.round(py*100.0))/100.0;
System.out.println("POINT "+getO(px)+" "+getO(py));
}
}
System.out.println("END OF OUTPUT");
}

public static String getO(double d){
String ds=""+d;
while (true){
int index=0;
boolean flag=false;
for (int j=0;j< ds.length() ;j++ ){
if (flag){
index++;
}
if (ds.charAt(j)=='.'){
flag=true;
}
}
if (index==2){
break;
}
else if (index==1){
ds=ds+"0";
}
}
return ds;
}
}

```
This entry was posted in poj. Bookmark the permalink.