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