Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- double triangle(double x1,double y1,double x2,double y2,double x3,double y3)
- {
- double ans1=(x1*y2)+(x2*y3)+(x3*y1);
- double ans2=(y1*x2)+(y2*x3)+(y3*x1);
- return ans1-ans2;
- }
- void myfunc(double a1,double b1,double c1,double a2,double b2,double c2)
- {
- double x=(b1*c2-b2*c1)/(double)(a1*b2-a2*b1);
- double y=(c1*a2-c2*a1)/(double)(a1*b2-a2*b1);
- //cout<<fixed<<setprecision(2);
- printf("POINT %.02lf %.02lf\n",x,y);
- }
- int main()
- {
- //freopen("378.txt","r",stdin);
- //freopen("378out.txt","w",stdout);
- int t,flag=0;
- cin>>t;
- while(t--)
- {
- double x1,y1,x2,y2,x3,y3,x4,y4;
- cin>>x1>>y1>>x2>>y2>>x3>>y3>>x4>>y4;
- if(!flag){
- cout<<"INTERSECTING LINES OUTPUT"<<endl;
- flag=1;
- }
- if(x1!=x2)
- {
- double slope1=(y1-y2)/(x1-x2);
- double slope2=(y3-y4)/(x3-x4);
- // cout<<slope1<<" "<<slope2<<endl;
- if(slope1==slope2)
- {
- double area=triangle(x1,y1,x2,y2,x3,y3);
- if(area==0.0)
- {
- cout<<"LINE"<<endl;
- }
- else
- {
- cout<<"NONE"<<endl;
- }
- }
- else
- {
- double a1,b1,c1,a2,b2,c2;
- a1=y2-y1;
- b1=x1-x2;
- c1=(y1*x2)-(x1*y2);
- a2=y4-y3;
- b2=x3-x4;
- c2=(y3*x4)-(x3*y4);
- myfunc(a1,b1,c1,a2,b2,c2);
- }
- }
- else
- {
- /*cout<<x1<<" "<<y1<<endl;
- cout<<x2<<" "<<y2<<endl;
- cout<<x3<<" "<<y3<<endl;
- cout<<x4<<" "<<y4<<endl;*/
- double area1=triangle(x1,y1,x2,y2,x3,y3);
- double area2=triangle(x1,y1,x2,y2,x4,y4);
- if(area1==0.0 && area2==0.0)
- {
- cout<<"LINE"<<endl;
- continue;
- }
- double a1,b1,c1,a2,b2,c2;
- a1=y2-y1;
- b1=x1-x2;
- c1=(y1*x2)-(x1*y2);
- a2=y4-y3;
- b2=x3-x4;
- c2=(y3*x4)-(x3*y4);
- myfunc(a1,b1,c1,a2,b2,c2);
- }
- }
- cout<<"END OF OUTPUT"<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement