88 lines
2.0 KiB
Java
88 lines
2.0 KiB
Java
package LanQiaoOJ;
|
||
/*1-输入两个正整数 A,B,请你计算 A+B,并输出。*/
|
||
import java.util.Scanner;
|
||
/*
|
||
public class LanqiaoOJ_0001 {
|
||
|
||
public static void main(String[] args) {
|
||
Scanner sc=new Scanner(System.in);
|
||
while(sc.hasNext()) {
|
||
int a=sc.nextInt();
|
||
int b=sc.nextInt();
|
||
System.out.println(a+b);
|
||
}
|
||
}
|
||
}
|
||
*/
|
||
//2-输入n表示n组数,每组输入两个数,请计算出每组数的和。
|
||
/*
|
||
public class LanqiaoOJ_0001 {
|
||
|
||
public static void main(String[] args) {
|
||
Scanner sc=new Scanner(System.in);
|
||
while(sc.hasNext()) {
|
||
int n=sc.nextInt();//读入有几组测试数据
|
||
for(int i=0;i<n;i++) {
|
||
int a=sc.nextInt();
|
||
int b=sc.nextInt();
|
||
System.out.println(a+b);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
*/
|
||
/*
|
||
* 3-输入包含多个测试用例。每个测试用例都包含一个整数N,然后N个整数在同一行中。每个整数以及同一行整数之和都在int范围内
|
||
以0开始的测试用例会终止输入,并且不会处理该测试用例。
|
||
输出
|
||
对于每组输入整数,您应该为每行输入数据输出一行,在这行中输出它们的总和*/
|
||
/*
|
||
public class LanqiaoOJ_0001 {
|
||
i
|
||
public static void main(String[] args) {
|
||
Scanner sc=new Scanner(System.in);
|
||
while(sc.hasNext()) {
|
||
int n=sc.nextInt();//读入有几组测试数据
|
||
if(n==0)
|
||
break;
|
||
int sum=0;//用来记录每次累加的值
|
||
for(int i=0;i<n;i++) {
|
||
sum+=sc.nextInt();//循环n次,每次读入一个正数,累加到sum
|
||
}
|
||
System.out.println(sum);
|
||
}
|
||
}
|
||
}
|
||
*/
|
||
|
||
/*
|
||
* 4-输入
|
||
* 在第一行包含一个整数N,然后跟随N行。每行以一个整数M开始,然后M个整数跟在同一行中。
|
||
输出
|
||
对于每组输入整数,您应该在一行中输出它们的总和,并且在输入中为每行输出一行输出。每组数据间用空行隔开
|
||
*/
|
||
public class AB问题 {
|
||
|
||
public static void main(String[] args) {
|
||
Scanner sc=new Scanner(System.in);
|
||
while(sc.hasNext()) {
|
||
int n=sc.nextInt();//读入每组组测试数据有几个
|
||
int t=sc.nextInt();//读入有几组测试数据
|
||
int sum=0;//用来记录每次累加的值
|
||
for(int j=0;j<t;j++) {
|
||
for(int i=0;i<n;i++) {
|
||
sum+=sc.nextInt();//循环n次,每次读入一个正数,累加到sum
|
||
}
|
||
System.out.println(sum);
|
||
}
|
||
System.out.println();
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
|