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