Skip to content

Instantly share code, notes, and snippets.

@sumitsingh6
Created June 23, 2019 19:43
Show Gist options
  • Select an option

  • Save sumitsingh6/4eaa59c6f9bb3abb38a5e9643a3b98b8 to your computer and use it in GitHub Desktop.

Select an option

Save sumitsingh6/4eaa59c6f9bb3abb38a5e9643a3b98b8 to your computer and use it in GitHub Desktop.
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Addrev {
public static void main(String[] args)throws Exception {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
int count = Integer.parseInt(in.readLine());
Integer input[][] = new Integer[count][2];
for(int i = 0; i < count; i++) {
StringTokenizer tk = new StringTokenizer(in.readLine());
input[i][0] = Integer.parseInt(tk.nextToken());
input[i][1] = Integer.parseInt(tk.nextToken());
}
for(int i = 0; i < count; i++) {
int sum = reverse(input[i][0]) + reverse(input[i][1]);
System.out.println(reverse(sum));
}
}
static int reverse(int num) {
int rev = 0;
while(num != 0) {
int digit = num % 10;
rev = rev * 10 + digit;
num /= 10;
}
return rev;
}
}
@sumitsingh6
Copy link
Copy Markdown
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment