반응형
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
package algo.fifth.a1546;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.StringTokenizer;
public class Main {
public static void main(String[] args) throws Exception{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
//receives input and divides by stringtokeinzer
int n = Integer.parseInt(br.readLine());
double[] arr = new double[n];
String str = br.readLine();
StringTokenizer st = new StringTokenizer(str);
//max for finding the highest number
double max = 0;
int t = 0;
while(st.hasMoreTokens()) {
arr[t] = Integer.parseInt(st.nextToken());
if(max < arr[t]) max = arr[t];
t++;
}
//doulbe is used for avg, followed the given equation to solve
double avg = 0;
t = 0;
for(; t < arr.length; t++) {
arr[t] = (arr[t]/ max) * 100;
avg += arr[t];
}
avg /= n;
}
}
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
|
반응형
'IT > 알고리즘' 카테고리의 다른 글
백준 5단계(4344) (0) | 2019.11.28 |
---|---|
백준 5단계(8958) (0) | 2019.11.28 |
백준 5단계(3052) (0) | 2019.11.28 |
백준 5단계(2577) (0) | 2019.11.28 |
백준 5단계(2920) (0) | 2019.11.28 |