You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
601 B

using System;
public class Program
{
public static void Main()
{
int[] A = {-7, 1, 5, 2, -4, 3, 0};
int length = A.Length;
int sum1=0, sum2=0;
if(A.Length < 3)
{
System.Console.Write("-1");
}
else
{
for(int i = 1; i<length; i++)
{
for(int j=0; j<length; j++)
{
System.Console.Write("j:"+j+" "+"i:"+i+" ");
if(A[j] < A[i])
{
sum1 +=A[j];
}
if(A[j] > A[i] && A[j]<length)
{
sum2 +=A[j];
}
}
if(sum1 ==sum2)
{
System.Console.Write(i);
break;
}
}
}
}
}