ArrayList ๋ฐฐ์ฐ๋ ์ด ๊ฒ ๊ฐ๋ค. ํ์ด ํ๋ ๋ ์๊ธด ๋๋.
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
ArrayList<Integer> a = new ArrayList<>();
ArrayList<Integer> b = new ArrayList<>();
while(true){
a.add(sc.nextInt());
b.add(sc.nextInt());
if(a.contains(0)&&b.contains(0))
break;
}
if(a.contains(0)&&b.contains(0)){
a.remove(a.size()-1);
b.remove(b.size()-1);
}
int[] c = new int[a.size()];
for (int i = 0; i < a.size(); i++) {
c[i] = a.get(i) + b.get(i);
System.out.println(c[i]);
}
}
}
0