Original Post
I tried to post in the other two threads about it, but they're retired.
So long story, short. Why is this wrong? I didn't see the sample array they used to test the code so I had to go by was the sample array they had.
[Edited by - Alpha_ProgDes on December 25, 2010 9:54:54 AM]
So long story, short. Why is this wrong? I didn't see the sample array they used to test the code so I had to go by was the sample array they had.
int equi ( int[] A ) { long equiIndex = -1; long equiTotal = 0; if (A.Length == 0) { return (int)equiIndex; } if (A == null) { return (int)equiIndex; } foreach (int i in A) { equiTotal += i; } for (long j = 0; j < A.Length; ++j) { if (A[j] == - (equiTotal - A[j])) { equiIndex = j; break; //even with this still wrong } } return (int)equiIndex; }[Edited by - Alpha_ProgDes on December 25, 2010 9:54:54 AM]