Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2019
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.90 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Test
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. int firstNumber = int.Parse(Console.ReadLine());
  10. int secondNumber = int.Parse(Console.ReadLine());
  11. int leftSum = 0;
  12. int rightSum = 0;
  13. int extraSum = 0;
  14.  
  15. for (int i = firstNumber; i <= secondNumber; i++)
  16. {
  17. int number = i;
  18. leftSum = 0;
  19. rightSum = 0;
  20. extraSum = 0;
  21.  
  22.  
  23. for (int j = 5; j >= 1; j--)
  24. {
  25. int one = number % 10;
  26. int rest = number / 10;
  27. number = rest;
  28.  
  29. if (j > 3)
  30. {
  31. rightSum += one;
  32. }
  33. else if (j == 3)
  34. {
  35. extraSum += one;
  36. }
  37. else if (j < 3)
  38. {
  39. leftSum += one;
  40. }
  41. }
  42.  
  43. if (leftSum == rightSum)
  44. {
  45. Console.Write(i + " ");
  46. }
  47. else
  48. {
  49. if (leftSum > rightSum)
  50. {
  51. rightSum += extraSum;
  52. if (leftSum == rightSum)
  53. {
  54. Console.Write(i + " ");
  55. }
  56. }
  57. else if (leftSum < rightSum)
  58. {
  59. leftSum += extraSum;
  60. if (leftSum == rightSum)
  61. {
  62. Console.Write(i + " ");
  63. }
  64. }
  65. }
  66.  
  67.  
  68. }
  69. }
  70. }
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement