下面的 C++ 用于对 lstA 排序,使得偶数在前奇数在后,横线处应填入 ( )。
bool isEven(int N){ return N % 2 == 0; }
void swap(int &a, int &b){ int t = a; a = b; b = t; }
void sortA(int lstA[], int n){
int i, j;
for (i = n - 1; i > 0; i--)
for (j = 0; j < i; j++)
if (________________)
swap(lstA[j], lstA[j + 1]);
}
- A. !isEven(lstA[j]) && isEven(lstA[j+1])
- B. isEven(lstA[j]) && !isEven(lstA[j+1])
- C. lstA[j] > lstA[j+1]
- D. lstA[j] < lstA[j+1]
正确答案:A