Guest User

Untitled

a guest
Oct 23rd, 2018
923
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.70 KB | None | 0 0
  1. using System;
  2.  
  3. class EqualSumsEvenOddPosition
  4. {
  5.     static void Main(string[] args)
  6.     {
  7.         int start = int.Parse(Console.ReadLine());
  8.         int end = int.Parse(Console.ReadLine());
  9.  
  10.         for (int i = start; i <= end; i++)
  11.         {
  12.             int currentNumber = i;
  13.             int oddSum = 0;
  14.             int evenSum = 0;
  15.             while (currentNumber > 0)
  16.             {
  17.                 oddSum += currentNumber % 10;
  18.                 currentNumber /= 10;
  19.                 evenSum += currentNumber % 10;
  20.                 currentNumber /= 10;
  21.             }
  22.             if (oddSum == evenSum)
  23.             {
  24.                 Console.Write(i + " ");
  25.             }
  26.         }
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment