-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path11.cpp
53 lines (52 loc) · 1.07 KB
/
11.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include<iostream>
using namespace std;
int main(){
double x1,x2,y1,y2,x3,x4,y3,y4;
cin>>x1>>y1>>x2>>y2>>x3>>y3>>x4>>y4;
double a=y2-y1;
double b=x1-x2;
double c=x1*y2-y1*x2;
int flag1,flag2;
if(a*x3+b*y3>c){
flag1=1;
}
else{
if(a*x3+b*y3==c){
flag1=2;
}
else{
flag1=0;
}
}
if(a*x4+b*y4>c){
flag2=1;
}
else{
if(a*x4+b*y4==c){
flag2=2;
}
else{
flag2=0;
}
}
if(flag1==flag2){
if(flag1==2){
cout<<"P1 and P2 are both in the straight line!"<<endl;
}
else{
cout<<"P1 and P2 are on the same side of the straight line!"<<endl;
}
}
else{
if(flag1==2){
cout<<"P1 is in the straight line!"<<endl;
}
else if(flag2==2){
cout<<"P2 is in the straight line!"<<endl;
}
else{
cout<<"P1 and P2 are not on the same side of the straight line!"<<endl;
}
}
return 0;
}