코딩테스트

[코딩테스트] 백준 자바 5번 사분면 고르기 (백준 14681번)

원코딩 2022. 10. 9. 18:01

 

 

 

1. 스캐너 

import java.util.*;

public class Main{
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int x=scan.nextInt();
		int y=scan.nextInt();
		
		if(x>0)
		{
			if(y>0)System.out.println("1");
			else System.out.println("4");
		
		}
		else {
			if(y>0)System.out.println("2");
			else System.out.println("3");
		}
	}
}

 

 

 

2. BufferedReader

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		int x=Integer.parseInt(br.readLine());
		int y=Integer.parseInt(br.readLine());
		if(x>0)
		{
			if(y>0)System.out.println("1");
			else System.out.println("4");
		
		}
		else {
			if(y>0)System.out.println("2");
			else System.out.println("3");
		}
	}
}