题解 | 多组_一维数组_T组形式
多组_一维数组_T组形式
https://www.nowcoder.com/practice/90cdc8e31ef74b6e9fd44c1e03077b57
import java.util.Scanner;
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
// 注意 hasNext 和 hasNextLine 的区别
while (in.hasNextInt()) { // 注意 while 处理多个 case
int a = in.nextInt();
for(int j=0;j<a;j++){
int b=in.nextInt();
long temp=0;
for(int m=0;m<b;m++){
temp=in.nextInt()+temp;
}
System.out.println(temp);
}
}
}
}
查看12道真题和解析