Advertisement
Guest User

Untitled

a guest
Oct 27th, 2019
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Equal_Sums_Left_Right_Position
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. int min = int.Parse(Console.ReadLine());
  10. int max = int.Parse(Console.ReadLine());
  11.  
  12. for (int num = min; num <= max; num++)
  13. {
  14. string number = num.ToString();
  15. int leftSum = int.Parse(number[0].ToString()) + int.Parse(number[1].ToString());
  16. int rightSum = int.Parse(number[3].ToString()) + int.Parse(number[4].ToString());
  17.  
  18. if (leftSum > rightSum)
  19. {
  20. rightSum += int.Parse(number[2].ToString());
  21.  
  22. }
  23. else if (leftSum < rightSum)
  24. {
  25. leftSum += int.Parse(number[2].ToString());
  26.  
  27. }
  28.  
  29.  
  30. if (leftSum == rightSum)
  31. {
  32. Console.Write(num + " ");
  33. }
  34. }
  35. }
  36. }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement