본문 바로가기
코딩테스트

[백준][java] 3009 네 번째 점

by 미소5 2023. 8. 2.

 

  • 배열에 직접 입력받을 수 있다.
int[] a = { sc.nextInt(), sc.nextInt() };	// 첫 번째 좌표
int[] b = { sc.nextInt(), sc.nextInt() };	// 두 번째 좌표
int[] c = { sc.nextInt(), sc.nextInt() };	// 세 번째 좌표

 

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		 Scanner sc=new Scanner(System.in);
		 int[] a = { sc.nextInt(), sc.nextInt() };	// 첫 번째 좌표
		 int[] b = { sc.nextInt(), sc.nextInt() };	// 두 번째 좌표
		 int[] c = { sc.nextInt(), sc.nextInt() };	// 세 번째 좌표
		 
		 int x=0, y=0;
		 if(a[0]==b[0]) {
			 x=c[0];
		 }
		 else if(a[0]==c[0]) {
			 x=b[0];
		 }
		 else if(b[0]==c[0]) {
			 x=a[0];
		 }
		 
		 if(a[1]==b[1]) {
			 y=c[1];
		 }
		 else if(a[1]==c[1]) {
			 y=b[1];
		 }
		 else if(b[1]==c[1]) {
			 y=a[1];
		 }
			
		 System.out.println(x+" "+y);
    }
}
728x90
반응형

'코딩테스트' 카테고리의 다른 글

[백준] 10808 알파벳 개수 - 자바(JAVA)  (0) 2023.08.09
[백준] 2563 색종이 -자바(JAVA)  (0) 2023.08.09
백준 10773 java  (0) 2023.07.09
백준 2908 java  (0) 2023.07.06
백준 11654 java  (0) 2023.07.06