-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path1182.java
40 lines (29 loc) · 876 Bytes
/
1182.java
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
import java.io.IOException;
import java.util.Locale;
import java.util.Scanner;
public class Main {
public static void main(String[] args) throws IOException {
Scanner sc = new Scanner(System.in);
Locale.setDefault(Locale.US);
int C = sc.nextInt();
double soma = 0;
char T = sc.next().toUpperCase().charAt(0);
double[][] M = new double[12][12];
for (int i = 0; i < 12; i++) {
for (int j = 0; j < 12; j++) {
M[i][j] = sc.nextDouble();
}
}
for(int i=0;i<12;i++) {
for(int j=0;j<12;j++) {
if(j==C) {
soma += M[i][j];
}
}
}
if (T == 'M') {
soma /= 12;
}
System.out.println(String.format("%.1f", soma));
}
}