AcWing 743. 数组中的行 - Java
原题链接
简单
作者:
KYCygni
,
2021-03-16 03:04:55
,
所有人可见
,
阅读 236
Java 代码
import java.util.Scanner;
public class Main
{
public static void main(String[] args)
{
Scanner cin = new Scanner(System.in);
int n = cin.nextInt();
String s = cin.next();
for (int i = 0; i < 12; i ++)
{
String m = cin.nextLine();
if (i == n)
{
double sum = 0;
for (int j = 0; j < 12; j ++)
{
sum += Double.valueOf(cin.next());
}
if (s.compareTo("S") == 0)
System.out.println (String.format("%.1f", sum));
else if (s.compareTo("M") == 0)
System.out.println (String.format("%.1f", sum / 12.0));
break;
}
}
}
}