Skip to content

Commit

Permalink
Feat: CCW 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
soopeach committed Sep 10, 2023
1 parent 8e0c394 commit 91919a6
Showing 1 changed file with 62 additions and 0 deletions.
62 changes: 62 additions & 0 deletions src/main/kotlin/hyunsoo/44week/CCW.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package hyunsoo.`44week`

/**
*
* <문제>
* [CCW](https://www.acmicpc.net/problem/11758)
*
* - 아이디어
*
* [참고](https://velog.io/@jini_eun/%EB%B0%B1%EC%A4%80-11758%EB%B2%88-CCW-Java-Python)
*
* x1 x2 x3 x4
* y1 y2 y3 y4
* - 트러블 슈팅
*
*/
class `전현수_CCW` {

private data class Point(val x: Int, val y: Int)

fun solution() {
val p = Array(3) {
readln().split(" ")
.map { it.toInt() }
.run {
Point(first(), last())
}
}

val first = (0..2).run {
var triangle = 0
this.forEach { index ->
triangle += p[index % 3].x * p[(index + 1) % 3].y
}
triangle
}

val second = (1..3).run {
var triangle = 0
this.forEach { index ->
triangle += p[index % 3].y * p[(index + 1) % 3].x
}
triangle
}

val answer = first - second
println(
if (0 < answer) {
1
} else if (answer < 0) {
-1
} else {
0
}
)

}
}

fun main() {
전현수_CCW().solution()
}

0 comments on commit 91919a6

Please sign in to comment.