Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int n = Integer.parseInt(scanner.nextLine()),
- index, leftNumber, rigthNumber, sum = 0;
- String input, left, rigth, number;
- for (int i = 0; i < n; i++) {
- input = scanner.nextLine();
- index = input.indexOf(" ");
- left = input.substring(0, index);
- rigth = input.substring(index + 1);
- number = Long.parseLong(left) > Long.parseLong(rigth) ? left : rigth;
- for (int j = 0; j < number.length(); j++) {
- if (number.charAt(j) == '-') {
- continue;
- }
- sum += Integer.parseInt(number.substring(j, j + 1));
- }
- System.out.println(sum);
- sum = 0;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement