https://swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AV5Pw_-KAdcDFAUq
Arrays.sort๋ก ์ต์ ๊ฐ, ์ต๋๊ฐ 1๊ฐ์ฉ๋ง ๋นผ๊ณ ,
์์ 1๋ฒ์งธ ์๋ฆฌ์์ ๋ฐ์ฌ๋ฆผ = Math.round(์ธ์) ๊ทธ๋ฆฌ๊ณ (int)๋ก ํ๋ณํ
import java.util.Scanner;
import java.util.Arrays;
class Solution
{
public static void main(String args[]) throws Exception
{
Scanner kb = new Scanner(System.in);
int T=kb.nextInt();
for(int test_case=1; test_case<=T; test_case++){
int[] arr=new int[10];
for(int i=0; i<10; i++){
arr[i]=kb.nextInt();
}
Arrays.sort(arr);
int sum=0;
for(int i=1; i<9; i++){
sum+=arr[i];
}
System.out.println("#"+test_case+" "+(int)Math.round(sum/8.0));
}
}
}
'๐ ์ฝ๋ฉํ ์คํธ > ๋ฐฑ์ค & ํ๋ก๊ทธ๋๋จธ์ค' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[SWEA][JAVA]D3 : ์ก์ด (0) | 2022.11.03 |
---|---|
[SWEA][JAVA]D3 : ๋ฐ๋ฐ (0) | 2022.11.03 |
[ํ๋ก๊ทธ๋๋จธ์ค][JAVA]Level 1 : ์ฝ๋ผ ๋ฌธ์ (0) | 2022.11.03 |
[ํ๋ก๊ทธ๋๋จธ์ค][JAVA]Level 0 : ์ผ๊ฐํ์ ์์ฑ์กฐ๊ฑด(2) (0) | 2022.11.03 |
[SWEA][JAVA] ์ผ์์ผ (0) | 2022.11.02 |