Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace FromLeftToTheRight
- {
- class Program
- {
- static void Main(string[] args)
- {
- int num = int.Parse(Console.ReadLine());
- for (int i = 0; i < num; i++)
- {
- string number = Console.ReadLine();
- string number1 = string.Empty;
- string number2 = string.Empty;
- long sum1 = 0;
- long sum2 = 0;
- int x = 0;
- for (int j = 0; j < number.Length; j++)
- {
- if (number[j] == ' ')
- {
- x++;
- j++;
- }
- if (x == 1)
- {
- number2 += number[j];
- }
- else
- {
- number1 += number[j];
- }
- }
- long n1 = long.Parse(number1);
- long n2 = long.Parse(number2);
- if (n1 >= n2)
- {
- for (int y = 0; y < number1.Length; y++)
- {
- if (n1 % 10 == '-')
- {
- break;
- }
- else
- {
- sum1 += n1 % 10;
- n1 /= 10;
- }
- }
- Console.WriteLine(Math.Abs(sum1));
- }
- else
- {
- for (int z = 0; z < number2.Length; z++)
- {
- if (n2 % 10 == '-')
- {
- break;
- }
- else
- {
- sum2 += n2 % 10;
- n2 /= 10;
- }
- }
- Console.WriteLine(Math.Abs(sum2));
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement