Advertisement
Guest User

Untitled

a guest
Jan 25th, 2020
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. using System;
  2.  
  3. namespace FromLeftToTheRight
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. int inputLines = int.Parse(Console.ReadLine());
  10.  
  11. for (int i = 1; i <= inputLines; i++)
  12. {
  13. string currentString = Console.ReadLine();
  14.  
  15. string[] array = currentString.Split(' ');
  16. long firstNumber = long.Parse(array[0]);
  17. long secondNumber = long.Parse(array[1]);
  18.  
  19. long currentDigit = 0;
  20. long sumOfDigits = 0;
  21.  
  22. if (firstNumber >= secondNumber)
  23. {
  24. while (firstNumber > 0)
  25. {
  26. currentDigit = firstNumber % 10;
  27. sumOfDigits += currentDigit;
  28. firstNumber = firstNumber / 10;
  29. }
  30. Console.WriteLine(sumOfDigits);
  31. }
  32. else if (secondNumber >= firstNumber)
  33. {
  34. while (secondNumber > 0)
  35. {
  36. currentDigit = secondNumber % 10;
  37. sumOfDigits += currentDigit;
  38. secondNumber = secondNumber / 10;
  39. }
  40. Console.WriteLine(sumOfDigits);
  41. }
  42. }
  43. }
  44. }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement