题解 | 多组_一维数组_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 的区别 int a = in.nextInt(); int[] res = new int[a]; for (int i = 0; i < a; i ++) { int n = in.nextInt(); in.nextLine(); String[] s = in.nextLine().split(" "); Long sum = 0L; int[] list = new int[n]; for (int j = 0; j < n; j ++) { list[j] = Integer.parseInt(s[j]); sum += list[j]; } System.out.println(sum); } } }