JAVA/백준
# 14681 - 사분면 고르기 [백준 문제풀이]
못지(Motji)
2021. 5. 25. 22:49
14681 번 문제풀이
1번 제출
import java.util.Scanner;
public class Main{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int x = sc.nextInt();
int y = sc.nextInt();
if(x>0 && y>0) {
System.out.println(1);
}else if(x<0 && y>0) {
System.out.println(2);
}else if(x<0 && y<0) {
System.out.println(3);
}else if(x>0 && y>0) {
System.out.println(4);
}
}
}
틀림 - 마지막 부등호 잘못씀 ㅎ;
2번째 제출 - 맞음 짝짞짝
import java.util.Scanner;
public class Main{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int x = sc.nextInt();
int y = sc.nextInt();
if(x>0 && y>0) {
System.out.println(1);
}else if(x<0 && y>0) {
System.out.println(2);
}else if(x<0 && y<0) {
System.out.println(3);
}else if(x>0 && y<0) {
System.out.println(4);
}
}
}