Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- class Program
- {
- static void Main()
- {
- int[] numbers = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
- int maxNumber = numbers.Max(); //Gets the max number of the array
- int totalSumOfNumber = numbers.Sum(); //Gets the total sum of the numbers in the array
- int check = (totalSumOfNumber - maxNumber) / 2; //Gets the sum of the numbers int the array without the max number
- if (check == maxNumber) //Checks if the sum is equal to the max number
- {
- int index1 = Array.IndexOf(numbers, numbers.Max());
- Console.WriteLine("{0}", index1);
- }
- else
- {
- if (numbers.Length == 1)
- {
- Console.WriteLine(0);
- }
- else
- {
- Console.WriteLine("no");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement