BufferedReader 풀이1
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());
int Quadrant = 4;
if(x>0 && y>0) {
Quadrant = 1;
}else if(x<0 && y>0) {
Quadrant = 2;
}else if(x<0 && y<0) {
Quadrant = 3;
}else {
}
System.out.println(Quadrant);
}
}
BufferedReader 풀이2
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());
int Quadrant = 0;
if(x>0) {
if(y>0) {
Quadrant = 1;
}else {
Quadrant = 4;
}
}else {
if(y>0) {
Quadrant = 2;
}else {
Quadrant = 3;
}
}
System.out.println(Quadrant);
}
}
'알고리즘 풀이' 카테고리의 다른 글
[백준]2525번:오븐 시계 - java 풀이 (0) | 2023.03.27 |
---|---|
[백준]2884번:알람시계 - java 풀이 (0) | 2023.03.26 |
[백준]9498번:시험 성적 - java 풀이 (0) | 2023.03.25 |
[백준]1330번: 두 수 비교하기 - java 풀이 (0) | 2023.03.25 |
[백준]2588번: 곱셈 - java 풀이 (0) | 2023.03.25 |