본문 바로가기

코딩 이야기/백준 풀이

백준 11758번: CCW C++코드(기하학)

반응형

#include<iostream>

using namespace std;

int just(int x1, int x2, int x3, int y1, int y2, int y3){
    int temp = (x2-x1)*(y3-y1) - (y2-y1)*(x3-x1);
    temp = temp/2;
    if(temp > 0){
        return 1;
    }else if(temp == 0){
        return 0;
    }else if(temp < 0){
        return -1;
    }

}

int main(){
    int x1,y1,x2,y2,x3,y3;
    cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
    cout << just(x1,x2,x3,y1,y2,y3);
}
반응형