Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package MoreExercise;
- import java.util.Arrays;
- import java.util.Scanner;
- public class FromLeftToTheRight {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int n = Integer.parseInt(scanner.nextLine());
- for (int i = 1; i <= n; i++) {
- String[] array= scanner.nextLine().split(" ");
- String first = array[0];
- String second = array[1];
- long firstNum = Long.parseLong(first);
- long secondNum = Long.parseLong(second);
- int sum = 0;
- long number = 0;
- if (firstNum > secondNum) {
- number = Math.abs(firstNum);
- } else {
- number = Math.abs(secondNum);
- }
- while (number > 0) {
- long currentDigit = number % 10;
- sum += currentDigit;
- number = number / 10;
- }
- System.out.println(sum);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment