알고리즘 문제/BOJ
11758번 CCW
parkit
2018. 10. 28. 11:40
728x90
반응형
http://hsdevelopment.tistory.com/123
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 | #include <iostream> #include <queue> #include <stack> #include <cstdio> #include <vector> #include <cstring> #include <string> #include <math.h> #include <algorithm> #include <map> using namespace std; int ccw(int x1, int y1, int x2, int y2, int x3, int y3) { int temp = x1*y2 + x2*y3 + x3*y1; temp = temp - y1*x2 - y2*x3 - y3*x1; if (temp > 0) return 1; // 반시계 else if (temp < 0) return -1; // 시계 else return 0; // 일직선 } int main(void) { int x1 = 0, y1 = 0, x2 = 0, y2 = 0, x3 = 0, y3 = 0; scanf("%d %d %d %d %d %d", &x1, &y1, &x2, &y2, &x3, &y3); printf("%d\n", ccw(x1, y1, x2, y2, x3, y3)); return 0; } | cs |
728x90
반응형