Advertisement
spasnikolov131

Untitled

Sep 29th, 2021
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. using System;
  2.  
  3. namespace From_Left_to_the_Right
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. int input = int.Parse(Console.ReadLine());
  10. int sumOfLeftNumber = 0;
  11. int sumOfRightNumber = 0;
  12. int sum = 0;
  13.  
  14.  
  15. for (int i = 0; i <= input; i++)
  16. {
  17. int leftNumber = Convert.ToInt32(Console.ReadLine());
  18. int rightNumber = Convert.ToInt32(Console.ReadLine());
  19.  
  20. if (leftNumber > rightNumber)
  21. {
  22. while (leftNumber > 0)
  23. {
  24. int lastDigit = leftNumber % 10;
  25. sum += lastDigit;
  26. leftNumber /= 10;
  27.  
  28. }
  29.  
  30. }
  31. else
  32. {
  33. while (rightNumber > 0)
  34. {
  35. int lastDigit = rightNumber % 10;
  36. sum += lastDigit;
  37. rightNumber /= 10;
  38.  
  39. }
  40. }
  41. Console.WriteLine(sum);
  42. }
  43. }
  44. }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement