题目详情

函数main(  )、f(  )的定义如下所示。调用函数f(  )时,第一个参数采用传值(call by value) 方式,第二个参数采用传引用(call by reference)方式,main(  )执行后输出的值为(  )。

中级软件评测师,历年真题,2019年下半年(上午)《软件评测师》真题

  • A.2
  • B.3
  • C.8
  • D.10

正确答案及解析

正确答案
C
解析

传值调用:形参取的是实参的值,形参的改变不会导致调用点所传的实参的值发生改变。

引用(传址)调用:形参取的是实参的地址,即相当于实参存储单元的地址引用,因此其值的改变同时就改变了实参的值。

在函数执行的过程中,f(5,x)?f(int x,int &a)可以得出第一个参数x的取值为5(第一个参数为传值调用);第二个参数a取得左边main()函数中x的地址(第二个参数为传址调用);当运行x=2*a-1后,f()函数中x的取值变为3(2*2-1);当运行a=x+5后,a对应地址的取值被修改为8,也就是将main()函数中的x值修改为8;当运行return后,f()函数结束。这时main()函数中的x取值为8;所以当main()函数答应x值时,应该输出为8。

包含此试题的试卷

你可能感兴趣的试题

单选题

Advancements in ( )have contributed to the growth of the automotive industry through the creation and evolution of self-driving vehicles.

  • A.Artificial Intelligence
  • B.Cloud Computing
  • C.Internet of Things
  • D.Big Data
查看答案
单选题

In project human resource management , ( )is not a source of power for the project manager.

  • A.referent power
  • B.expert power
  • C.reward power
  • D.audit power
查看答案
单选题

At the project establishment stage , the feasibility study mainly includes techinical feasibility analysis , ( ), operation environment feasibility analysis and other aspects of feasibility analysis.

  • A.detail feasibility analysis
  • B.opportunity analysis
  • C.economic feasibility analysis
  • D.risk analysis
查看答案
单选题

( )is a grid that shows the project resources assigned to each work package.

  • A.Stakeholder engagement assessment matrix
  • B.Requirements traceability matrix
  • C.Probability and impact matrix
  • D.Responsibility assignment matrix
查看答案
单选题

Xinhua News Agency reported in January 2022,Chian will further promote the developmet of a digital economy during the 14th Five-Year Plan eriod(2021-2025). The plan also emphasized industrial ( )transformation.

  • A.digital
  • B.networking
  • C.intelligentize
  • D.informatization
查看答案

相关题库更多 +