牛客輸入輸出練習1-計算a+b(多組輸入)
題目描述
計算多組輸入的a+b
示例
輸入輸出描述:
輸入描述:
輸入包括兩個正整數a,b(1 <= a, b <= 10^9),輸入數據包括多組。
輸出描述:
輸出a+b的結果
例如2:
輸入:
1 5
10 20
輸出:
6
30
Java代碼
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner scanner = new Scanner(System.in);
ArrayList<Integer> lis = new ArrayList<Integer>();
while(scanner.hasNextLine()){
String[] lines = scanner.nextLine().split(" ");
int a = Integer.parseInt(lines[0]);
int b = Integer.parseInt(lines[1]);
lis.add(a+b);
}
//輸出
for(Integer i : lis){
System.out.println(i);
}
}
}
輸出
已AC