Advertisement
Guest User

Untitled

a guest
Jan 29th, 2020
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Left_to_the_right
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. int n = int.Parse(Console.ReadLine());
  10.  
  11. for (int i = 0; i < n; i++)
  12. {
  13. string numbers = Console.ReadLine();
  14. char delimeter = ' ';
  15.  
  16. string[] splitNumbers = numbers.Split(delimeter);
  17.  
  18. long leftNum = long.Parse(splitNumbers[0]);
  19. long rightNum = long.Parse(splitNumbers[1]);
  20.  
  21. long biggerNumber = rightNum;
  22.  
  23. if (leftNum > rightNum)
  24. {
  25. biggerNumber = leftNum;
  26. }
  27.  
  28. long sumOfDigits = 0;
  29.  
  30. while (biggerNumber != 0)
  31. {
  32. sumOfDigits += biggerNumber % 10;
  33. biggerNumber /= 10;
  34. }
  35.  
  36. Console.WriteLine(Math.Abs(sumOfDigits));
  37. }
  38. }
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement