Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace _02.EqualSumsEvenOddPosition
- {
- internal class Program
- {
- static void Main(string[] args)
- {
- int start = int.Parse(Console.ReadLine());
- int end = int.Parse(Console.ReadLine());
- for (int i = start; i <= end; i++)
- {
- string number = i.ToString();
- int evenSum = 0;
- int oddSum = 0;
- for (int j = 0; j < number.Length; j++)
- {
- int currentDigit = int.Parse(number[j].ToString());
- if (j % 2 == 0)
- {
- evenSum += currentDigit;
- }
- else
- {
- oddSum += currentDigit;
- }
- }
- if (evenSum == oddSum)
- {
- Console.Write($"{i} ");
- }
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment