#3347. [GESP202312 五级 C++] 第 4 题

[GESP202312 五级 C++] 第 4 题

下面的C++用于对 lstA 排序,使得偶数在前奇数在后,横线处应填入( )。

bool isEven(int N)
{
    return N % 2 == 0;
}

void swap(int &a, int &b)
{
    int t;
    t=a,a=b,b=t;
    return;
}

void sortA(int lstA[], int n)
{
    int i,j,t;
    for (i = n-1; i > 0; i--)
        for(j = 0; j < i; j++)
            if(______________________________)
                swap(lstA[j], lstA[j+1]);

    return;
}

{{ select(1) }}

  • !isEven(lstA[j]) && isEven(lstA[j+1])
  • isEven(lstA[j]) && !isEven(lstA[j+1])
  • lstA[j] > lstA[j+1]
  • lstA[j] < lstA[j+1]