题目详情

阅读以下代码和问题,回答问题,将解答填入答题纸的对应栏内。

初级程序员,章节练习,基础复习,案例分析

初级程序员,章节练习,基础复习,案例分析

初级程序员,章节练习,基础复习,案例分析

1.【问题1】

对于代码1,写出下面的函数调用后x1、x2、x3和x4的值。

x1=f(1997);

x2=f(2000);

x3=f(2100);

x4=f(2020);

2.【问题2】

(1)写出代码2进行时输入为3的输出结果;

(2)写出代码2进行时输入为5的输出结果。

3.【问题3】

写出代码3运行后的输出结果。

正确答案及解析

正确答案
解析

【问题1】x1=3;x2=0;x3=2;x4=1

解析:1997:不满足0==yr%400,不满足!(yr%4)==1,所以返回D;

2000:满足0==yr%400,返回A;

2100:不满足0==yr%400,满足!(yr%4)==1,不满足0!=yr%100,返回C;

2020:不满足0==yr%400,满足!(yr%4)==1,满足0!=yr%100,返回B。

枚举类型中列出的每一个枚举符都对应着一个整数值,枚举类型实际上是一个整型符号常量的集合。当定义枚举类型时,枚举符都已经被系统隐含地赋予了一个整型值,默认情况下,第一个元素为0,第二个元素为1,依此类推。所以相应的A=0,B=1,C=2,D=3,故返回为:x1=3;x2=0;x3=2;x4=1。

【问题2】(1)Average!

poor!

Oops,Error

(2)Excellent!

Good!

解析:进入switch后会与各case匹配,从第一个匹配到的case开始执行,直到结束或者遇到break。

【问题3】0 1 0

0 2 0

0 2 1

1 0 1

1 2 0

1 2 1

解析:此题考察多重for循环再加上一个判定条件,i的取值为(0,1),j的取值为(0,1,2),k的取值为(0,1),只要按顺序找到i!=j且j!=k的组合即可。

你可能感兴趣的试题

单选题

The Internet of( 1)(IoT) describes physical objects that are embedded with Sensor,processing abilities,softwares,and other technologies that connect with other devices and systems over the ( 2) or other communication and exchange data networks .Over the past few years, IoT has become one of the most important technologies of the ( 3 ) centuryWe can connect objects to the Internet via embedded devices. By means of( 4) computing, the cloud, big data, and mobile technologies, physical things can share and collect data with minimal human intervention. Traditional fields of embedded systems,wireless ( 5) networks (WSNs),control systems,automation, independently and collectively enable IoT.回答5处

  • A.sensor
  • B.searching
  • C.service
  • D.source
查看答案
单选题

The Internet of( 1)(IoT) describes physical objects that are embedded with Sensor,processing abilities,softwares,and other technologies that connect with other devices and systems over the ( 2) or other communication and exchange data networks .Over the past few years, IoT has become one of the most important technologies of the ( 3 ) centuryWe can connect objects to the Internet via embedded devices. By means of( 4) computing, the cloud, big data, and mobile technologies, physical things can share and collect data with minimal human intervention. Traditional fields of embedded systems,wireless ( 5) networks (WSNs),control systems,automation, independently and collectively enable IoT.回答4处

  • A.low-level
  • B.low-cost
  • C.high-cost
  • D.high-performance
查看答案
单选题

The Internet of( 1)(IoT) describes physical objects that are embedded with Sensor,processing abilities,softwares,and other technologies that connect with other devices and systems over the ( 2) or other communication and exchange data networks .Over the past few years, IoT has become one of the most important technologies of the ( 3 ) centuryWe can connect objects to the Internet via embedded devices. By means of( 4) computing, the cloud, big data, and mobile technologies, physical things can share and collect data with minimal human intervention. Traditional fields of embedded systems,wireless ( 5) networks (WSNs),control systems,automation, independently and collectively enable IoT.回答3处

  • A.19th
  • B.20th
  • C.21th
  • D.22th
查看答案
单选题

The Internet of( 1)(IoT) describes physical objects that are embedded with Sensor,processing abilities,softwares,and other technologies that connect with other devices and systems over the ( 2) or other communication and exchange data networks .Over the past few years, IoT has become one of the most important technologies of the ( 3 ) centuryWe can connect objects to the Internet via embedded devices. By means of( 4) computing, the cloud, big data, and mobile technologies, physical things can share and collect data with minimal human intervention. Traditional fields of embedded systems,wireless ( 5) networks (WSNs),control systems,automation, independently and collectively enable IoT.回答2处

  • A.path
  • B.Internet
  • C.route
  • D.switch
查看答案
单选题

The Internet of( 1)(IoT) describes physical objects that are embedded with Sensor,processing abilities,softwares,and other technologies that connect with other devices and systems over the ( 2) or other communication and exchange data networks .Over the past few years, IoT has become one of the most important technologies of the ( 3 ) centuryWe can connect objects to the Internet via embedded devices. By means of( 4) computing, the cloud, big data, and mobile technologies, physical things can share and collect data with minimal human intervention. Traditional fields of embedded systems,wireless ( 5) networks (WSNs),control systems,automation, independently and collectively enable IoT.回答1处

  • A.this
  • B.thing
  • C.think
  • D.things
查看答案

相关题库更多 +