nikolayneykov

Untitled

Feb 3rd, 2019
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.71 KB | None | 0 0
  1. using System;
  2.  
  3. class Program
  4. {
  5.     static void Main(string[] args)
  6.     {
  7.         int lines = int.Parse(Console.ReadLine());
  8.  
  9.         for (int i = 0; i < lines; i++)
  10.         {
  11.             string numbers = Console.ReadLine();
  12.             int index = numbers.IndexOf(' ');
  13.  
  14.             long first = long.Parse(numbers.Substring(0, index));
  15.             long second = long.Parse(numbers.Substring(index));
  16.             long biggestNumber = first > second ? first : second;
  17.  
  18.             long sum = 0;
  19.             while (biggestNumber != 0)
  20.             {
  21.                 sum += biggestNumber % 10;
  22.                 biggestNumber /= 10;
  23.             }
  24.             Console.WriteLine(Math.Abs(sum));
  25.         }
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment