| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |
Tags
- Adapter
- Hexagonal
- hexagonal architecture
- Spring Data JPA
- Layered Architecture
- JPA
- transactional
- Spring
- springboot
- JDBC
- 실무
- simplejpaRepository
- Transaction
Archives
- Today
- Total
Ezcho
CCW 알고리즘 본문
CCW 알고리즘
ccw는 평면에 놓여진 세 점의 방향관계를 구하는 알고리즘이다.
세 점을 주어진 순서대로 벡터화 한후 그 두 백터를 외적하면 방향이 정의된다.
-코드 [Java]
import java.util.Scanner;
public class Main {
public static void main(String args[]){
Scanner sc = new Scanner(System.in);
int x1 = sc.nextInt();
int y1 = sc.nextInt();
int x2 = sc.nextInt();
int y2 = sc.nextInt();
int x3 = sc.nextInt();
int y3 = sc.nextInt();
int a = x1 * y2 + x2 * y3 + x3 * y1;
int b = y1 * x2 + y2 * x3 + y3 * x1;
if(a-b==0)
System.out.println(0);
else if(a-b>0)
System.out.println(1);
else
System.out.println(-1);
}
}'Algorithm > 기하' 카테고리의 다른 글
| [2166]다각형 면적 구하기(코드+풀이) (0) | 2022.09.24 |
|---|---|
| 평면벡터 클래스 (0) | 2022.09.05 |
Comments
