백준 #18414번 X に最も近い値 (The Nearest Value)

jhj·2024년 2월 13일

백준 JAVA

목록 보기
260/583
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int x = sc.nextInt();
		int l = sc.nextInt();
		int r = sc.nextInt();
		int min = l;
		int a;
		
		if(x > r) {
			min = r;
		}else if(x < l) {
			min = l;
		}else {
			min = x;
		}
		
		System.out.println(min);
		sc.close();
	}
}
profile
개발자를 꿈꾸는

0개의 댓글