Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2021
358
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _02.From_left_to_the_Right
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9.  
  10. int numOfInputs = int.Parse(Console.ReadLine());
  11.  
  12. for (int i = 0; i < numOfInputs; i++)
  13. {
  14. long num1Value = 0L;
  15. long num2Value = 0L;
  16.  
  17. string[] input = Console.ReadLine().Split(" ", StringSplitOptions.RemoveEmptyEntries);
  18.  
  19. //these two variables are not needed but make the code more readable
  20. string num1 = input[0];
  21. string num2 = input[1];
  22.  
  23. long leftNumber = long.Parse(num1);
  24. long rightNumber = long.Parse(num2);
  25.  
  26. for (int k = 0; k < num1.Length; k++)
  27. {
  28. bool isDigit = long.TryParse(num1[k].ToString(), out long digit);
  29. num1Value += digit;
  30. }
  31.  
  32. for (int v = 0; v < num2.Length; v++)
  33. {
  34. bool isDigit = long.TryParse(num2[v].ToString(), out long digit);
  35. num2Value += digit;
  36. }
  37.  
  38. if (leftNumber > rightNumber)
  39. {
  40. Console.WriteLine(num1Value);
  41. }
  42. else
  43. {
  44. Console.WriteLine(num2Value);
  45. }
  46. }
  47. }
  48. }
  49. }
  50.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement