Not exactly - the function returns an undefined value for a size of 1, and a 1 or -1 if the LAST element of the array is "ascending" or "descending" in relation to the first element. But it says nothing at all meaningfull about the elements in between. So if you have 10 12 13 14 15 17 19 9, then it's not ascending according to your function, whilst 10 1 2 3 4 5 6 12 is - I don't think either is ascending properly - but maybe I don't understand what ascending and descending arrays are correctly - I never studied math at a higher level.Quote:
The ascend function returns 1 if it does ascend and -1 if it does not. the same is for the descend.
This is still quite wrong. I think you can see that if you actually read those lines.Code:if (seconval < 0){
firsval = 1.0;
seconval= 1/firsval;
}
Other than those few things, I think you're pretty close. Have you actually tested your code with some real data, and checked the results?
--
Mats