๋ฐ์ํ
import java.util.Scanner;
// 1546 ํ๊ท
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int subjectNum = sc.nextInt();
double m = 0;
double sum = 0;
double[] subjectArr = new double[subjectNum];
for (int i = 0; i < subjectNum; i++) {
subjectArr[i] = sc.nextInt();
}
sc.close();
for (int i = 0; i < subjectArr.length; i++) {
m = Math.max(m, subjectArr[i]);
}
for (int i = 0; i < subjectArr.length; i++) {
subjectArr[i] = subjectArr[i]/m*100;
sum += subjectArr[i];
}
System.out.println(sum/subjectNum);
}
}
- ์ถ๋ ฅ์ด 66.666667 ์ด๋ฐ์์ด๊ธฐ ๋๋ฌธ์ double์ ๋ด์์ค์ผ ํ๋ค๋ ํจ์ ์ด ์์์ต๋๋ค.
- ์ต๋๊ฐ๋ง Math.max()๋ฅผ ์ด์ฉํด ๊ตฌํด์ฃผ๋ฉด ์ฝ๊ฒ ๊ณ์ฐํ ์ ์์ต๋๋ค.
๋ฐ์ํ
'๐ธ Algorithm > ๐ธ ๋ฐฑ์ค BaekJoon' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[๋ฐฑ์ค][java][27866][๋ฌธ์์ ๋ฌธ์์ด] (2) | 2023.12.03 |
---|---|
[๋ฐฑ์ค][java][3052][๋๋จธ์ง] (0) | 2023.11.26 |
[๋ฐฑ์ค][java][10811][๋ฐ๊ตฌ๋ ๋ค์ง๊ธฐ] (0) | 2023.11.12 |
[๋ฐฑ์ค][java][5597][๊ณผ์ ์ ๋ด์ ๋ถ..?] (0) | 2023.11.12 |
[๋ฐฑ์ค][java][10813][๊ณต ๋ฐ๊พธ๊ธฐ] (0) | 2023.11.05 |