程序填空题:The Largest Missing Integer
Given an array `a[]`of `n` integers, the function `MissingMax` is to find and return the maximum negative integer which is **NOT** in the array. For example, given { -3, -1, 8, 1, 0 }, -2 is the largest negative integer which is missing.
```c++
int MissingMax( int a[], int n )
{
int i, j, max, missing = -1;
for( i=0; i max = i;
for( j = i+1; j < n; j++ )
if (@@[a[j]>a[max]](3)) max = j;
if ( max != i ) swap(a[i], a[max]);
if ( a[i] == missing ) missing--;
else if ( a[i] < missing ) @@[break](3);
}
return missing;
}
```
答案:
第1空:a[j]>a[max]
第2空:break
```c++
int MissingMax( int a[], int n )
{
int i, j, max, missing = -1;
for( i=0; i
for( j = i+1; j < n; j++ )
if (@@[a[j]>a[max]](3)) max = j;
if ( max != i ) swap(a[i], a[max]);
if ( a[i] == missing ) missing--;
else if ( a[i] < missing ) @@[break](3);
}
return missing;
}
```
答案:
第1空:a[j]>a[max]
第2空:break