DyNaMiXx7

Untitled

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