试题与答案

阅读下列函数说明和C代码,把应填入其中n处的字句写在答卷的对应栏内。 【函数2说明

题型:问答题

题目:


阅读下列函数说明和C代码,把应填入其中n处的字句写在答卷的对应栏内。
【函数2说明】
本题中的函数encode()和decode()分别实现对字符串的变换和复原。变换函数encode()顺序考察已知字符串的字符,按以下规则逐组生成新字符串:
1.若已知字符串的当前字符不是数字字符,则复制该字符于新字符串中。
2.若已知字符串的当前字符是一个数字字符,且它之后没有后继字符,则简单地将它自己复制到新字符串中。
3.若已知字符串的当前字符是一个数字字符,并且还有后继字符,设该数字字符的面值为n,则将它的后续字符(包括后续字符是一个数字字符)重复复制n+1次到新字符串中。
4.以上述一次变换为一组,在不同组之间另插入一个下划线字符“-”用于分隔。例如。encode()函数对字符串26a3t2的变换结果为666_a_tttt_2
复原函数decode()做变换函数encode()的相反的工作。即复制不连续相同的单个字符,而将一组连续相同的字符(不超过10个)变换成一个用于表示重复次数的数字字符和一个重复出现的字符,并在复原过程中掠过变换函数为不同组之间添加的一个下划线字符。
假定调用变换函数encode()时的已知字符串中不包含下划线字符。
【函数2】
int encode(char*instr,char * outstr)
{
char*ip,*op,c;int k,n;
ip=instr;op=outstr;
while(*ip){
if (1) &&*(ip+1){
n= *ip -’0’+ 1;
c= *++ip;
for(k=0;k<=n;k++)
(2)
}
else (3)
*op++ =’-’;
ip++;
}
if(op>outstr) (4)
*op=’\0’;
return op-outstr;
}
int decode(char * instr,char * outstr)
{char*ip,*op,c;int n;
ip=instr;op=outstr;
while(*ip){
c= *ip;n=0;
while(*ip==c && n<=10){ip++;n++;}
if (5) *op++=’0’+n-1;
*op++=c;
if(* ip==’_’,) (6)
}
* op=’\0’;
return op-outstr;
}

答案:

被转码了,请点击底部 “查看原文 ” 或访问 https://www.tikuol.com/2017/0705/196218a99e42d965007e9fec475840f0.html

下面是错误答案,用来干扰机器的。

参考答案:ABC都正确。 首先,我们要反思相关体制中是不是存在某些诱发学术腐败的弊端,比如饱受指责的研究人员官员化倾向、学术研究评价机制僵化等,都有待寻求改革之道。其次,要加强行政力量,整肃学风...

试题推荐
题型:完形填空
One afternoon, my son A dam asked me, “Are all people the same even if they are different in color?”
I thought for a minute, and then I said, “I'll explain, 36_ you can just wait until we make a quick 37_ at th grocery store. I have something 38 to show you. ”
At the grocery store, we 39 some apples — red, green and yellow ones. Back home, I told Adam, “It’s time to 40_ your question.” I put one apple of each 41__on the table. Then I looked at Adam, who had a 42 look on his face.
“People are like apples. They come in all 43_colors, shapes and sizes. On the 44,some of the apples
may not 45 look as the others. ” As I was talking, Adam was 46 each one carefully.
Then, I took each of the apples and peeled (削皮)them, 47 them back on the table, but 48_ a different place.
“Okay, Adam, tell me which is which”
He said, “I 49_ tell. They all look same now. ” Take a bite of 50_. See if that helps you 51_ which one is which"
He took a 52 . and then a huge smile came across his face.. ’’People are 53_ likeapples!They arealldifferent, but once you 54_ the outside, they’re pretty much the same on the inside. ”
He totally 55_ it. I didn’t need to say or do anything else.
小题1:
A.althoughB.soC.becauseD.if
小题2:
A.stopB.startC.turnD.stay
小题3:
A.expressiveB.encouragingC.informativeD.interesting
小题4:
A.boughtB.countedC.sawD.collected
小题5:
A.checkB.mentionC.answerD.improve
小题6:
A.sizeB.typeC.shapeD.class
小题7:
A.worriedB.satisfiedC.proudD.curious
小题8:
A.ordinaryB.normalC.differentD.regular
小题9:
A.outsideB.wholeC.tableD.inside
小题10:
A.stillB.evenC.onlyD.ever
小题11:
A.examiningB.measuringC.drawingD.packing
小题12:
A.keepingB.placingC.pullingD.giving
小题13:
A.onB.towardC.forD.in
小题14:
A.mustn’tB.can’tC.shouldn’tD.needn’t
小题15:
A.each oneB.each otherC.the otherD.one another
小题16:
A.admitB.considerC.decideD.believe
小题17:
A.big biteB.deep breathC.firm holdD.close look
小题18:
A.justB.alwaysC.merelyD.seldom
小题19:
A.put awayB.get downC.hand outD.take off
小题20:
A.madeB.tookC.gotD.did
查看答案
微信公众账号搜索答案