问题 填空题

阅读以下说明和C程序,填充函数中的空缺。
[说明]
N个游戏者围成一圈,从1~N顺序编号,游戏方式如下;从第一个人开始报数(从1到3报数),凡报到3的人退出圈子,直到剩余一个游戏者为止,该游戏者即为获胜者。
下面的函数playing(Linklist head)模拟上述游戏过程并返回获胜者的编号。其中,N个人围成的圈用一个包含N个结点的单循环链表来表示,如图1所示,游戏者的编号放在结点的数据域中。


在函数中,以删除结点来模拟游戏者退出圈子的处理。整型变量c(初值为1)用于计数,指针变量p的初始值为head(如图1所示)。游戏时,从p所指向的结点开始计数,p沿链表中的指针方向遍历结点,c的值随p的移动相应地递增。当c计数到2时,就删除p所指结点的下一个结点(因下一个结点就表示报数到3的游戏者),如图2所示,然后将c设置为0后继续游戏过程。


结点类型定义如下:
typedef struct node
int code; /*游戏者的编号*/
struct node *next;
NODE, *LinkList;
[C函数]
int P1aying(LinkList head,int n)
/*head指向含有n个结点的循环单链表的第一个结点(即编号为1的游戏者)*/
LinkList p=head,q;
int thewinner,c=1;
while(n>______)
if(c==2) /*当c等于2时,p所指向结点的后继即为将被删除的结点*/
q=p->next;
p->next=______;
printf("%d\t",q->code); /*输出退出圈子的游戏者编号*/
free(q);
/*if*/
p=______;
/*while*/
theWinner=______;
free(p);
return theWinner; /*返回最后一个游戏者(即获胜者)的编号*/

答案

参考答案:A

单项选择题
阅读理解

阅读理解。

     This book is written expressly (清楚地) for students in an attempt to present the material that is most

useful and interesting to them. Previous courses in chemistry are not necessary for the understanding of the

material, although those students who have had high school chemistry will find that a review of the inorganic

section will better enable them to master the organic and biochemistry sections that follow.

     The author has felt that in the past there was an improper selection of material from inorganic, organic,

and biochemistry in the majority of the textbooks of chemistry for nurses. The tendency has been to develop

the inorganic chemistry to such an extent that organic and biochemistry are covered too briefly. The recent

advances in biochemistry and their widespread application to the practice of medicine and nursing have

considerably altered the situation. Not only is biochemistry more closely allied to the practical chemistry of

medicine and nursing, but also it is of more interest to the students. In the author's experience the response

to biochemistry has always been more favorable than to other sections. Within the brief period allotted to

 chemistry, therefore, the sections on inorganic, organic, and biochemistry should be so arranged that a good

share of the time is spent on the study of biochemistry. This book presents mainly those fundamentals of

inorganic and organic chemistry that are necessary for the understanding of the section on biochemistry.

    The fundamental points suggested in the Curriculum Guide are included in the book, with some additions

in the biochemistry section. The author feels that a study of urine, vitamins, nutrition, and hormones is so

obviously a part of biochemistry that at least the fundamentals should be included in this course.

     The book has been planned in such a way that it may be adapted to various courses in chemistry. The

material suggested by Curriculum Guide is covered in the first nineteen chapters and may be used in

accelerated courses or where minimum time is allotted to chemistry. When the time allotted to the course is

sixty to ninety hours, the entire contents of the book may be used to advantage. While the book has been

written especially to fit the needs of schools of nursing, it could readily be applied in instances where students

are required to take but one course in chemistry. The apathetic (无动于衷的) attitude of nonprofessional

students toward a course in inorganic chemistry may well be overcome by the proper presentation of material

selected from inorganic, organic, and biochemistry.

1. This piece of writing is _____.

A. an introduction to a course book

B. a professor's letter to his students

C. the record of an introductory speech

D. from a school announcement

2. To read this book _____.

A. previous course in chemistry are necessary

B. a good mastery of biochemistry is essential

C. one needn't have studied chemistry before

D. one must first review his high school courses

3. In the author's experience, the students are most interested in _____.

A. inorganic chemistry

B. biochemistry

C. organic chemistry

D. chemistry as a whole

4. The underlined word "allotted" in the last paragraph means _____.

A. separated

B. obtained

C. needed

D. distributed

5. Paragraph 4 suggests that one characteristic of this book is its _______.

A. simplicity in presentation

B. thoroughness in the field

C. vividness of the language

D. adaptability to various needs