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