Advertisement
Guest User

Untitled

a guest
Jul 20th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace _04.Equal_Sums_Even_Odd_Position
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. int n1 = int.Parse(Console.ReadLine());
  14. int n2 = int.Parse(Console.ReadLine());
  15.  
  16. for (int i = n1+1; i < n2; i++)
  17. {
  18. string currNumString = i.ToString();
  19. int sumEven = 0;
  20. int sumOdd = 0;
  21. int curNum = 0;
  22.  
  23. for (int j = 0; j < 6; j+=2)
  24. {
  25. curNum = (int)currNumString[j];
  26. sumEven += curNum;
  27. }
  28.  
  29. for (int j = 1; j < 6; j += 2)
  30. {
  31. curNum = (int)currNumString[j];
  32. sumOdd += curNum;
  33. }
  34.  
  35. if (sumEven == sumOdd)
  36. {
  37. Console.Write(i + " ");
  38. }
  39.  
  40. }
  41. }
  42. }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement