Problem Statement
This is the second challenge in the introduction series. The purpose of this challenge is to give you a working I/O template in your preferred language. It includes scanning two space-separated integers from T lines, calling a function, returning a value, and printing it to
STDIN
in a loop over STDOUT
.
A pseudo code looks like the following:
read T
loop from 1 to T
read A and B
compute the sum
print value in a newline
end loop
Input Format
The first line containsT (number of test cases) followed by T lines
Each line containsA and B , separated by a space.
The first line contains
Each line contains
As you can see that we have provided in advance the number of lines, we discourage the use of scanning till T line to indicate the number of lines.
EOF
as not every language has an easy way to handle that. In fact, every HackerRank challenge is designed in such a way that multitests begin with a
Sample Input
2
2 3
3 7
Sample Output
5
10
import java.io.*;
import java.util.*;
class Solution
{
{
static int solveMeSecond(int a, int b)
{
{
return a+b;
}
public static void main(String[] args)
{
{
Scanner in = new Scanner(System.in);
int t;
int sum;
int a,b;
t = in.nextInt();
for (int i=0;i<t;i++)
{
{
a = in.nextInt();
b = in.nextInt();
sum = solveMeSecond(a, b);
System.out.println(sum);
}
}
}