A和B求和问题

 1 import java.util.Scanner;
 2 public class AB求和问题 {
 3     public static void main(String[] args) {
 4         Scanner scanner=new Scanner(System.in);
 5         /*
 6         while (scanner.hasNext()) {
 7             int n1=scanner.nextInt();
 8             int n2=scanner.nextInt();
 9             System.out.println(n1+n2);
10         }
11         */
12         /*
13         int N=scanner.nextInt();
14         for(int i=0;i<N;i++) {
15             int n1=scanner.nextInt();
16             int n2=scanner.nextInt();
17             System.out.println(n1+n2);
18         }
19         */
20         /*
21         while (scanner.hasNext()) {
22             int n1=scanner.nextInt();
23             int n2=scanner.nextInt();
24             if(!(n1==0&&n2==0)) {
25                 System.out.println(n1+n2);
26             }
27         }*/
28         /*
29         while(scanner.hasNext()) {
30             int done=scanner.nextInt();
31             if(done!=0) {
32                 int sum=0;
33                 for(int i=0;i<done;i++) {
34                     sum+=scanner.nextInt();
35                 }
36                 System.out.println(sum);
37             }
38         }*/
39         /*
40         int N=scanner.nextInt();
41         for(int i=1;i<=N;i++) {
42             int M=scanner.nextInt();
43             int sum=0;
44             for(int j=0;j<M;j++) {
45                 sum+=scanner.nextInt();
46             }
47             System.out.println(sum);
48         }
49         */
50         /*
51         while(scanner.hasNext()) {
52             int M=scanner.nextInt();
53             int sum=0;
54             for(int j=1;j<=M;j++) {
55                 sum+=scanner.nextInt();
56             }
57             System.out.println(sum);
58         }
59         */
60         /*
61         while (scanner.hasNext()) {
62             int n1=scanner.nextInt();
63             int n2=scanner.nextInt();
64             System.out.println(n1+n2);
65             System.out.println();
66         }*/
67         int N=scanner.nextInt();
68         for(int i=1;i<=N;i++) {
69             int M=scanner.nextInt();
70             int sum=0;
71             for(int j=0;j<M;j++) {
72                 sum+=scanner.nextInt();
73             }
74             System.out.println(sum);
75             System.out.println();
76         }
77         scanner.close();
78     }
79 }

猜你喜欢

转载自www.cnblogs.com/kongchung/p/9729243.html