Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace While_Loop
- {
- class Program
- {
- static void Main(string[] args)
- {
- int firstNum = int.Parse(Console.ReadLine());
- int secondNum = int.Parse(Console.ReadLine());
- for (int currentNum = firstNum; currentNum <= secondNum; currentNum++)
- {
- int evenSum = 0;
- int oddSum = 0;
- string current = currentNum.ToString();
- for (int i = 0; i < current.Length; i++)
- {
- char currentDigit = current[i];
- if (i % 2 != 0) // even
- {
- evenSum += int.Parse(currentDigit.ToString());
- }
- else
- {
- oddSum += int.Parse(currentDigit.ToString());
- }
- }
- if (evenSum == oddSum)
- {
- Console.Write(current + " ");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement