题目详情

阅读以下说明和C代码,填补代码中的空缺,将解答填入答题纸的对应栏内。

【说明1】

递归函数is_elem(char ch, char *set)的功能是判断ch中的字符是否在set表示的字符集合中,若是,则返回1,否则返回0。

【C代码1】

int is_elem (char ch ,char*set)

{

if(*set==‘\0’)

return 0;

else

if( (1) )

return 1;

else

return is_elem( (2) )

}

【说明2】

函数char*combine(char* setA,char *setB)的功能是将字符集合A(元素互异,由setA表示)和字符集合B(元素互异,由setB表示)合并,并返回合并后的字符集合。

【C代码2】

char*combine(char *setA, char*setB)

{

int i,lenA, lenB, lenC;

lenA=strlen(setA);

lenB=strlen(setB);

char*setC=(char*)malloc(lenA+lenB+1);

if(!setC)

return NULL;

strncpy(setC,setA,lenA); //将setA的前lenA个字符复制后存入setC

lenC= (3) ;

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

if( (4) ) //调用is_elem判断字符是否在setA中

setC[lenC++]=setB[i];

(5) =‘/0’; //设置合并后字符集的结尾标识

return setC;

}

正确答案及解析

正确答案
解析

(1)set[0]==ch或*set==ch或其他等价形式(2)ch,set+1或ch,++set或其他等价形式(3)lenA或其他等价形式(4)is_elem(setB[i],*setA)==0或!is_elem(setB[i],*setA)或其他等价形式(5)setC[lenC]或其他等价形式

【解析】

If(set[0]==ch)//取出set第一个元素与ch字符比较是否相等return is_elem(ch,*set-1) // 从set第二个元素开始重新递归代入函数执行strncpy(setC,setA,lenA); //将setA的前lenA个字符复制后存入setClenC=lenA;for(i=0;i<lenB;i++)ifis_elem(setB[i],*setA)==0) //调用is_elem判断字符是否在setA中setC[lenC++]=setB[i];setC[lenC+1]=‘/0’;//设置合并后字符集的结尾标识returnsetC;

你可能感兴趣的试题

单选题

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

相关题库更多 +