728x90
๋ฐ์ํ
โ๋ฌธ์
https://www.acmicpc.net/problem/1546
๐์ ํ
์ํ, ์ฌ์น์ฐ์ฐ
โ๐ปํ์ด
A, B, C๋ผ๋ ์ ์๊ฐ ์๋ค๋ฉด
(A/M*100 + B/M*100 + C/M*100)/3์ ๊ฒฐํฉ๋ฒ์น์ ์ํด (A+B+C)*100/M/3๊ณผ ๊ฐ๋ค
๊ทธ๋ฌ๋ฏ๋ก ๋จผ์ ์ ์์ ํฉ์ ๊ตฌํ๊ณ ๊ทธ์ ๋์์ ์ต๋๊ฐ๋ ๊ตฌํ๋ค.
๐ป์ฝ๋
import java.util.*;
public class Main {
static int n;
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
n = sc.nextInt();
float[] score = new float[n];
for (int i = 0; i < n; i++) {
score[i] = sc.nextInt();
}
float m = 0;
float sum = 0;
for (int i = 0; i < n; i++) {
if (score[i] > m) {
m = score[i];
}
sum += score[i];
}
System.out.println(sum * 100.0/ m / n);
}
}
728x90
๋ฐ์ํ
'Coding Test > Algorithms' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[Baekjoon] 15649.N๊ณผ M (1)/Java - Silver3 (0) | 2024.09.29 |
---|---|
[ํ๋ก๊ทธ๋๋จธ์ค] ์ฃผ์๊ฐ๊ฒฉ/Java - Lv.2 (0) | 2024.09.29 |
[Baekjoon] 28278. ์คํ 2/Java - Silver4 (0) | 2024.09.28 |
[ํ๋ก๊ทธ๋๋จธ์ค] ์์/Python - Lv.3 (1) | 2024.09.28 |
[Baekjoon] 2750. ์ ์ ๋ ฌํ๊ธฐ/Java - Bronze2 (1) | 2024.09.28 |