SHARE
TWEET

ednakvisumi 4etni ne4etni pozicii

ss3434 Oct 20th, 2019 89 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top