BOJ 11758: CCW 작성일 2020-03-01 https://www.acmicpc.net/problem/11758 3월동안 210문제 풀기 (2/210) CCW가 외적인것을 배우는 문제. 그리고 기하 알고리즘의 기본인 Vector 클래스 디자인을 배우는 문제. 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081#include <bits/stdc++.h> using namespace std; const double EPS = 1e-9; struct Vector { double x, y; Vector(int x, int y) { this->x = x, this->y = y; } Vector(const Vector& v1) { x = v1.x, y =v1.y; } Vector(const Vector& v1, const Vector& v2) { x = v2.x - v1.x, y = v2.y - v1.y; } Vector& operator+=(const Vector &other) { x += other.x; y += other.y; return *this; } Vector& operator-=(const Vector &other) { x -= other.x; y -= other.y; return *this; } Vector& operator*=(const double C) { x *= C; y *= C; return *this; } Vector& operator/=(const double C) { x /= C; y /= C; return *this; } Vector operator+(const Vector &other) const { return Vector(*this) += other; } Vector operator-(const Vector &other) const { return Vector(*this) -= other; } Vector operator*(const double C) const { return Vector(*this) *= C; } Vector operator/(const double C) const { return Vector(*this) /= C; } }; double cross(Vector v1, Vector v2) { return v1.x * v2.y - v1.y * v2.x; } double ccw(Vector va, Vector vb) { double v = cross(va, vb); if(abs(v) < EPS) return 0; if(v > 0) return 1; if(v < 0) return -1; } double ccw(Vector vr, Vector va, Vector vb) { return ccw(va - vr, vb - vr); } int main() { int x1, x2, x3, y1, y2, y3; cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3; Vector v1(x1,y1), v2(x2,y2), v3(x3,y3); cout << ccw(v2, v3, v1); }