问题 问答题

设计将带表头的链表逆置的算法。

答案

参考答案:设单循环链表的头指针为head,类型为LinkList。逆置时需将每一个结点的指针域进行修改,使其原前驱结点成为后继。如果更改q结点的指针域时,设s指向其原前驱结点,P指向其原后驱结点,则只需进行q->next=s;操作即可,算法描述如下:
void invert(LinkList*head)
{//逆置head指针所指向的单循环链表
Linklist*P,*q,*S;
q=head;
p=head->next;
while(p!=head)//当表不为空时,逐个结点逆置
{
s=q;
q=p;
p=p->next;
q->next=s;
}
P->next=q;
}

完形填空
Everybody has one of those days when everything goes wrong. This is what happened to Harry. One morning, he got up very  31  because his clock stopped. He 32  to shave (刮脸) quickly and cut himself. When he got dressed, he got  blood (血) all over his 33 , so he had to find another one. The only other shirt that was clean 34  ironing (熨) .While he was ironing it, there was a knock at the door. It was the man to collect money for water. After he paid the water 35 and showed the man out, he found the iron had burnt a hole in his shirt. So he had to wear the one with the blood on it after all. By this time it was very late, so he  36 he couldn’t go to work by bus. He  37  for a taxi to take him to work, the taxi arrived and Harry 38  in. In another part of the town, a man had killed a woman  39  a knife and was seen to run away in a taxi. When  Harry’s taxi stopped outside his office, a policeman 40  to be standing there. He saw the blood on Harry’s shirt, and took him to the police station. He was  41  till 3 p.m.  42 the police found out that he was not the man they wanted. When he finally arrived  43 the office at about 4 p.m., his boss  44  a look at him and told him to find  45 job.
小题1:
A.earlyB.lateC.worriedlyD.fast
小题2:
A.triedB.hopedC.wishedD.wanted
小题3:
A.coatB.sweaterC.jacketD.shirt
小题4:
A.needB.neededC.needingD.to need
小题5:
A.moneyB.changeC.billD.pay
小题6:
A.wonderedB.thoughtC.believedD.decided
小题7:
A.lookedB.wishedC.waitedD.telephoned
小题8:
A.gotB.satC.cameD.entered
小题9:
A.byB.withC.inD.through
小题10:
A.seemedB.saidC.happenedD.appeared
小题11:
A.stoppedB.caughtC.leftD.kept
小题12:
A.At lastB.In the lastC.At the endD.By the end
小题13:
A.atB.inC.toD.from
小题14:
A.tookB.gaveC.showedD.has
小题15:
A.anotherB.the otherC.otherD.others
多项选择题