/***
Md. Namzul Hasan
Shahjalal University of Science & Technology,Sylhet.
hasan08sust@gmail.com
***/
#include<bits/stdc++.h>
using namespace std ;
typedef long long ll ;
typedef int in ;
typedef unsigned long long ull ;
const double pi = 2*acos(0) ;
#define maxi 40000
#define pf printf
#define sc scanf
#define pb push_back
#define MEM(x,y) (memset((x),(y),sizeof(x)))
#define MIN(x,y) ((x) < (y) ? (x) : (y))
#define MAX(x,y) ((x) > (y) ? (x) : (y))
#define load(array,size) for(int i=0 ; i<size ; i++) cin>>array[i] ;
#define new_line pf("\n")
#define clear_data(array) memset(array,0,sizeof(array))
#define highest_int 2147483647
int area(int x1,int y1,int x2,int y2,int x3,int y3)
{
return x1*y2-y1*x2+x2*y3-y2*x3+x3*y1-y3*x1;
}
int main()
{
int test ;
sc("%d",&test) ;
pf("INTERSECTING LINES OUTPUT\n") ;
while(test--)
{
int x1,y1,x2,y2,x3,y3,x4,y4 ;
cin>>x1>>y1>>x2>>y2>>x3>>y3>>x4>>y4 ;
if( area(x1,y1,x2,y2,x3,y3)==0 && area(x1,y1,x2,y2,x4,y4)==0)
{
pf("LINE\n") ;
continue ;
}
int a1 = y2-y1 ;
int b1 = x1 -x2 ;
int c1 = y1*x2 - x1*y2 ;
int a2 = y4 -y3 ;
int b2 = x3 -x4 ;
int c2 = y3*x4 - x3*y4 ;
int m = (a1*b2 - b1*a2) ; /// condition to be parallel
if(m==0)
{
pf("NONE\n") ;
continue ;
}
double x = ((b1*c2 - b2*c1)*1.0) / ((a1*b2 - a2*b1)*1.0) ;
double y = ((c1*a2 - c2*a1)*1.0) / ((a1*b2 - a2*b1)*1.0) ;
pf("POINT %.2lf %.2lf\n",x,y) ;
}
pf("END OF OUTPUT\n") ;
return 0;
}
Md. Namzul Hasan
Shahjalal University of Science & Technology,Sylhet.
hasan08sust@gmail.com
***/
#include<bits/stdc++.h>
using namespace std ;
typedef long long ll ;
typedef int in ;
typedef unsigned long long ull ;
const double pi = 2*acos(0) ;
#define maxi 40000
#define pf printf
#define sc scanf
#define pb push_back
#define MEM(x,y) (memset((x),(y),sizeof(x)))
#define MIN(x,y) ((x) < (y) ? (x) : (y))
#define MAX(x,y) ((x) > (y) ? (x) : (y))
#define load(array,size) for(int i=0 ; i<size ; i++) cin>>array[i] ;
#define new_line pf("\n")
#define clear_data(array) memset(array,0,sizeof(array))
#define highest_int 2147483647
int area(int x1,int y1,int x2,int y2,int x3,int y3)
{
return x1*y2-y1*x2+x2*y3-y2*x3+x3*y1-y3*x1;
}
int main()
{
int test ;
sc("%d",&test) ;
pf("INTERSECTING LINES OUTPUT\n") ;
while(test--)
{
int x1,y1,x2,y2,x3,y3,x4,y4 ;
cin>>x1>>y1>>x2>>y2>>x3>>y3>>x4>>y4 ;
if( area(x1,y1,x2,y2,x3,y3)==0 && area(x1,y1,x2,y2,x4,y4)==0)
{
pf("LINE\n") ;
continue ;
}
int a1 = y2-y1 ;
int b1 = x1 -x2 ;
int c1 = y1*x2 - x1*y2 ;
int a2 = y4 -y3 ;
int b2 = x3 -x4 ;
int c2 = y3*x4 - x3*y4 ;
int m = (a1*b2 - b1*a2) ; /// condition to be parallel
if(m==0)
{
pf("NONE\n") ;
continue ;
}
double x = ((b1*c2 - b2*c1)*1.0) / ((a1*b2 - a2*b1)*1.0) ;
double y = ((c1*a2 - c2*a1)*1.0) / ((a1*b2 - a2*b1)*1.0) ;
pf("POINT %.2lf %.2lf\n",x,y) ;
}
pf("END OF OUTPUT\n") ;
return 0;
}
No comments:
Post a Comment