[백준] 6840

당당·2023년 5월 27일
0

백준

목록 보기
134/179

https://www.acmicpc.net/problem/6840

📔문제

In the story Goldilocks and the Three Bears, each bear had a bowl of porridge to eat while sitting at his/her favourite chair. What the story didn’t tell us is that Goldilocks moved the bowls around on the table, so the bowls were not at the right seats anymore. The bowls can be sorted by weight with the lightest bowl being the Baby Bear’s bowl, the medium bowl being the Mama Bear’s bowl and the heaviest bowl being the Papa Bear’s bowl. Write a program that reads in three weights and prints out the weight of Mama Bear’s bowl. You may assume all weights are positive integers less than 100.


📝입력

Write a program that reads in three weights.


📺출력

prints out the weight of Mama Bear’s bowl


📝예제 입력 1

10
5
8

📺예제 출력 1

8

🔍출처

Olympiad > Canadian Computing Competition & Olympiad > 2007 > CCC 2007 Junior Division 1번


🧮알고리즘 분류

  • 구현

📃소스 코드

import java.util.Arrays;
import java.util.Scanner;

public class Code6840 {
    public static void main(String[] args) {
        int[] bowls=new int[3];
        Scanner sc=new Scanner(System.in);

        for(int i=0;i<3;i++){
            bowls[i]=sc.nextInt();
        }

        Arrays.sort(bowls);

        System.out.println(bowls[1]);
    }
}

📰출력 결과


📂고찰

배열에 세 수를 입력받아서 정렬한다음 1번째 인덱스 값이 엄마 곰의 그릇 무게다.

profile
MySQL DBA 신입 지원

0개의 댓글