题目详情

阅读以下说明和C函数,将应填入(n)处的字句写在答题纸的对应栏内。

【说明】

某单位准备进行一次选举,对指定的n名(n<80)候选人进行投票。为了简化选举工作,事先印制了写有这n名候选人姓名的选票,投票者只需将选中者名下的圆圈涂黑即可。规定每张选票上被涂黑的圆圈数不得超过3个,也不得少于1个,否则视为无效选票。投票结束后,所有选票经计算机扫描处理,形成了描述选票状态的文本文件。例如,

n=8时所形成的文件如下:

01011000

10010100

10011000

11111111

00000000

00111000

……

其中,每行表示一张选票的数据,每列代表一位候选者的得票情况。第i行第j列为1,表示第i张选票上投了第j名候选人1票。

函数statistic()的功能是读入选票数据,并统计每位候选者的得票数,函数返回有效选票数。

【C函数】

int statistic (FILE *fp,int candidate[ ],int n)

{ /* 从文件中读入选票数据,n为候选人数量(n<80),从有效选票中统计每位候选者

的得票数并存入candidate[],函数返回有效选票数 */

char str[80] /* str保存读入的一张选票数据 */

int I tag=0 /* tag用于判断每张选票是否有效 */

int q=0 /* q用于计算有效选票数 */

for(i=0:i<n; i++)

candidate[i]=0;

while( (1) ){

fgets(str, 80, fp):/* 读入一张选票数据 */

for(tag=0, i=0 ; ((2)) ;i++)

if (str[i] = = ’1 ’) tag++;

if((3)){/* 若是有效选票,则进行统计 */

( (4) );

for(i=0;i<n;i++)

if(str[i]= =‘1’)(5) ;

return q;

} /* statistic */

正确答案及解析

正确答案
解析

初级程序员,章节练习,初级程序员真题卷

你可能感兴趣的试题

单选题

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
查看答案

相关题库更多 +