-3

I was looking for some way to make calculations on values inside array. I know that I can sum the values, sort it or returs max/min. But I am novice and i do not find anything about harder math. I have formula: http://i.imgur.com/O5tNmMh.jpg (can't attach images yet...)

And I have an array [somex, somey, somex, somey,somex, somey, ....] Is it possible to calculate the thing like that?

4

1 回答 1

0

你需要一些这样的逻辑:

int current=0 ,previous=0,yoursum=0;
for(i=0;i<no. of elements in array;i++)
{

 current=arr[i];
 else
 {
  yoursum+=previous-current;
  previous=current;
  }
}
于 2013-07-01T09:00:00.503 回答