• Home
  • About
    • ming photo

      ming

      studying

    • Learn More
    • Twitter
    • Facebook
    • Instagram
    • Github
    • Steam
  • Archive
    • All Posts
    • All Tags
    • All categories
  • categories
    • HTML+CSS+JavaScript
    • JAVA
    • Algorithm
    • DB
    • JSP
    • 정보처리기사
    • Spring
    • Thymeleaf
    • 기술면접
  • Projects

CodeUp-1167-if

17 Feb 2021

CodeUP_1167

🎈 문제 링크

▶ JAVA 코드

import java.util.Scanner;
public class if_1167 {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		if(a<b && b<c) { 
			System.out.println(b);
		}
		if(a<c && c<b) {
			System.out.println(c);
		}
		if(b<a && a<c) {
			System.out.println(a);
		}
		if(b<c && c<a) {
			System.out.println(c);
		}
		if(c<a && a<b) {
			System.out.println(a);
		}
		if(c<b && b<a) {
			System.out.println(b);
		}else if(a==b && b==c) {
			System.out.println(b);
		}else if(a==b && b<c) {
			System.out.println(b);
		}else if (b==c && c<a) {
			System.out.println(c);
		}else if(c==a&&a<b) {
			System.out.println(a);
		}

	}

}

▶ 코드 설명

1) 입력받을 Scanner 객체 생성
2) 입력받은 정수 변수 a,b,c 에 할당
3) 조건문 생성

❓ 좀더 간결하게 코드를 짜는 방법 연구해보기

▶ 출력 결과창(Console) if_1167



Share Tweet +1