I don't how to explain the question that was asked, I think it was something like write a program using arrays that would subtract eash interger in the array? anyway something like this
array 1/2/5/10/17 then the next array would look like this 2/5/7 then keep subtracting until it reaches zero
heres what I have so far don't give me the answer but any hints would be helpful thanks :WAVE:
Int[] seqDiff(int[] a){
int[] temp= new int[a.length -1];
for(int i = 0; i<temp.length; i++)
tmp[i] =a[i+1]-a[i]
Return temp;
}
I don't know how to make it stop
11-01-2005, 06:23 AM
mr1yh1
1-)all elements of temp array's may reach zero
(there is no guarantee ).
you may check it with in a loop. i suggest to write a seperate function doing it . ( forexample boolean isSolved( int[] a) )
2-or you will have a list which include only 1 element ( non-zero ) so you cant go further.
this means method is not proper for that data
or you have not enough points ( data ) to solve it in that way.
you may search "newton interpolation"
to learn more abouth this method.