Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- namespace ConsoleApp1
- {
- internal class Program
- {
- static void Main(string[] args)
- {
- int[] input = Console.ReadLine()
- .Split()
- .Select(int.Parse)
- .ToArray();
- if (input.Length == 1)
- {
- Console.WriteLine($"0");
- return;
- }
- int sumLeft = 0;
- int sumRight = 0;
- for (int i = 0; i < input.Length; i++)
- {
- for (int j = 0; j < input.Length; j++)
- {
- if (input[i] > input[j])
- {
- sumLeft += input[j];
- }
- else if (input[i] < input[j])
- {
- sumRight += input[j];
- }
- else if (input[i] == input[j])
- {
- //Ако са еднакви числа едно след друго задачата се обърква и вади грешен вход.
- }
- }
- if (sumLeft == sumRight)
- {
- Console.WriteLine(input[i]);
- return;
- }
- sumLeft = 0;
- sumRight = 0;
- }
- Console.WriteLine($"no");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement