publicclassMain{ publicstaticvoidmain(String args[])throws IOException { BufferedReader bf = new BufferedReader(new InputStreamReader(System.in)); StringBuilder sb = new StringBuilder(); int n = Integer.parseInt(bf.readLine()); int res = 0; for(int i = 0; i < n; i++) { String[] line = bf.readLine().split(" "); res = Integer.parseInt(line[0]) + Integer.parseInt(line[1]); sb.append(res + "\n"); } System.out.println(sb); } }
Code (JAVA)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
import java.io.*;
publicclassMain{ publicstaticvoidmain(String args[])throws IOException { BufferedReader bf = new BufferedReader(new InputStreamReader(System.in)); BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); int n = Integer.parseInt(bf.readLine()); String res; for(int i = 0; i < n; i++) { String[] line = bf.readLine().split(" "); res = (Integer.parseInt(line[0]) + Integer.parseInt(line[1])) + "\n"; bw.write(res); } bw.flush(); } }