#4433. [GESP202603 八级 C++] 第 15 题

[GESP202603 八级 C++] 第 15 题

在64位操作系统下(LP64 / LLP64 模型),下面代码的输出结果是( )。

#include <iostream>
using namespace std;

int main() {
    int a[4] = {1, 2, 3, 4};
    int (*p)[4] = &a;
    int *q = a;

    cout << sizeof(a) << " ";
    cout << sizeof(p) << " ";
    cout << sizeof(p + 1) << " ";
    cout << sizeof(q + 1) << " ";
    cout << (p + 1) - p << " ";
    cout << (q + 1) - q << endl;
}

{{ select(1) }}

  • 16 8 8 8 1 1
  • 16 8 16 8 1 1
  • 16 8 8 4 4 1
  • 16 8 8 8 4 1