We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent f3a597e commit fb62b95Copy full SHA for fb62b95
C++/chapLinearList.tex
@@ -182,7 +182,7 @@ \subsubsection{代码}
182
int search(int A[], int n, int target) {
183
int first = 0, last = n;
184
while (first != last) {
185
- const int mid = (first + last) / 2;
+ const int mid = first + (last - first) / 2;
186
if (A[mid] == target)
187
return mid;
188
if (A[first] <= A[mid]) {
@@ -240,7 +240,7 @@ \subsubsection{代码}
240
bool search(int A[], int n, int target) {
241
242
243
244
245
return true;
246
if (A[first] < A[mid]) {
0 commit comments