세 정수 A, B, C가 주어진다. 이때, 두 번째로 큰 정수를 출력하는 프로그램을 작성하시오.
세 정수 A, B, C가 주어진다. 이때, 두 번째로 큰 정수를 출력하는 프로그램을 작성하시오.
두 번째로 큰 정수를 출력한다.
20 30 10
20
#include <iostream>
#include <algorithm>
using namespace std;
int main(void) {
int arr[3];
cin >> arr[0] >> arr[1] >> arr[2];
sort(arr, arr+3);
cout << arr[1] << "\n";
}
import java.util.Arrays;
import java.util.Scanner;
public class Main {
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
int[] arr = new int[3];
arr[0] = sc.nextInt();
arr[1] = sc.nextInt();
arr[2] = sc.nextInt();
Arrays.sort(arr);
System.out.println(arr[1]);
}
}