第二章 2.2.4节练习

时间:2022-10-01 16:08:13

练习2.13

下面程序中j的值是多少?

int i = 42;

int main(){

  int i = 100;

  int j = i;

}

解答:

100


练习2.14

下面的程序合法嘛?如果合法,它将输出什么?

int i = 100, sum = 0;

for (int i = 0; i != 10; ++i)

  sum += i;

std::cout << i << " " << sum << std::endl;

解答:

合法,会输出:100 45