O******i 发帖数: 269 | 1 void DutchFlag(int A[], int n)
{
if (A == NULL || n <= 1)
return;
int red = 0;
int blue = n - 1;
int current = 0;
while (current < blue)
{
if (is_red(A[current]))
{
swap(A, red, current);
red++;
current++;
}
else if (is_blue(A[current]))
{
swap(A, current, blue);
blue--;
}
else
current++;
}
} | e***l 发帖数: 710 | | O******i 发帖数: 269 | 3 给个使得输出结果不对的反例?
【在 e***l 的大作中提到】 : while (current <= blue)
| O******i 发帖数: 269 | |
|