Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace ConsoleApp1
- {
- class Program
- {
- static void Main(string[] args)
- {
- int smaller = int.Parse(Console.ReadLine());
- int bigger = int.Parse(Console.ReadLine());
- int leftSum = 0;
- int rightSum = 0;
- int middleSum = 0;
- int currentNumber = 0;
- for (int i = smaller; i <= bigger; i++)
- {
- currentNumber = i;
- leftSum = 0;
- rightSum = 0;
- middleSum = 0;
- for (int j = 5; j >= 0; j--)
- {
- int numCounter = currentNumber % 10;
- currentNumber = currentNumber / 10;
- if (j > 3)
- {
- rightSum += numCounter;
- }
- else if (j == 3)
- {
- middleSum += numCounter;
- }
- else if (j < 3)
- {
- leftSum += numCounter;
- }
- }
- if (leftSum == rightSum)
- {
- Console.Write($"{i} ");
- }
- else if (leftSum < rightSum && leftSum + middleSum == rightSum)
- {
- Console.Write($"{i} ");
- }
- else if (leftSum > rightSum && leftSum == middleSum + rightSum)
- {
- Console.Write($"{i} ");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment