Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace _04.OtherVersion
- {
- class Program
- {
- static void Main(string[] args)
- {
- int num1 = int.Parse(Console.ReadLine());
- int num2 = int.Parse(Console.ReadLine());
- int oddSum = 0;
- int evenSum = 0;
- int numberAsInt = 0;
- for (int i = num1; i <= num2; i++)
- {
- string currentNumber = i + ""; //правим го на стринг,
- //за да измерим дължината
- for (int j = 0; j < currentNumber.Length; j++)
- {
- numberAsInt = int.Parse(currentNumber[j].ToString());
- if (j % 2 == 0)
- {
- //numberAsInt = currentNumber[j];
- oddSum += numberAsInt;
- }
- else
- {
- evenSum += numberAsInt;
- }
- }
- if (evenSum == oddSum)
- {
- Console.Write(currentNumber + " ");
- }
- oddSum = 0;
- evenSum = 0;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment