我是 C++ 新手,很难理解这个函数。有人可以带我过去吗?
int seqSearch(int [ ] list, int target)
{
//precondition: The list is in non-decreasing order
//postcondition: The method returns -1 if the target is not in the list. If the target
//is in the list, the method returns the index of the first occurrence of the target.
int result = -1;
boolean foundBigger = false;
int i = 0;
while (result == -1 && !foundBigger && i < list.length)
{
if (target == list[i])
result = i;
else if (list[i] > target)
foundBigger = true;
//endif
i++;
} //endwhile
return result;
}