|
+
|
... |
#include <iostream>
#include <cstdio>
#include <complex>
using namespace std;
typedef complex<double> P;
#define x real()
#define y imag()
#define EPS (1e-10)
double cross (P a, P b) {
return a.x*b.y - a.y*b.x;
}
int is_cross(P a1, P a2, P b1, P b2) {
return (cross(a2-a1, b1-a1) * cross(a2-a1, b2-a1) < EPS) &&
(cross(b2-b1, a1-b1) * cross(b2-b1, a2-b1) < EPS);
}
int main() {
double xa,ya,xb,yb,xc,yc,xd,yd;
while (scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf",&xa,&ya,&xb,&yb,&xc,&yc,&xd,&yd) != EOF) {
P a(xa, ya);
P b(xb, yb);
P c(xc, yc);
P d(xd, yd);
if (is_cross(a, c, b, d)) cout << "YES" << endl;
else cout << "NO" << endl;
}
return 0;
}
|