问题 问答题


阅读以下程序说明和C程序,将应填入(n)处的字句,写在对应栏内。
【程序说明】
某网络由n个端点组成,这些端点被物理地分成若干个分离的端点组。同一组内的两件端点i和j,它们或直接相连,或间接相连(端点i和端点j间接相连是指在这两件端点之间有一个端点相连序列,其中端点i和j分别与这相连序列中的某个端点直接相连)。网络的n个端点被统一编号为0,1,…,n-1。本程序输入所有直接相连的端点号对,分别求出系统各分离端点组中的端点号并输出。
程序根据输入的直接相连的两件端点号,建立n个链表,其中第i个链表的首指针为s[i],其结点是与端点i直接相连的所有端点号。
程序依次处理各链表。在处理s[i]链表中,用top工作链表重新构造s[i]链表,使s[i]链表对应系统中的一个端点组,其中结点按端点号从小到大连接。
【程序】
#inelude
#define N 100
typeef struct node{
int data;
struct node *link;
}NODE;
NODE * s[N];
int i,j,n,t;
NODE *q,*p,*x,*y,*top;
main()
{
printf(“Enter namber of components.”);
scanf(“%d”,&n);
for(i=0;i<n;i++) printf(“Enter pairs.\n”);
while(scanf(“%d%d”,&i,&j)==2)
{ /*输入相连端点对,生成相连端点结点链表*/
p=(NODE*)malloc(sizeof(NODE));
p→data=j;p→link=s[i];s[i]=p;
p=(NODE*)malloc(sizeof(NODE));
p→data=i;p→link=s[j];s[j]=p;
}
for(i=0;i<n;i++) /*顺序处理各链表*/
for(top=s[i], (1) ;top! =NULL;)
{ /*将第i链表移入top工作链表,并顺序处理工作链表的各结点*/
q=top;
(2)
if(s¨[j=q→data]!=NULL)
{ /将j链表也移入工作链表*/
for(p=s[j];p→link! =NULL;p= p→link);
p→link= top;top=s[j];
(3)
}
/*在重新生成的第i链表中寻找当前结点的插入点*/
for(y=s[i]; (4) ;x=y,y=y→link);
if(y!=NULL && y→data==q→data)
free(q); /*因重新生成的第i链表已有当前结点,当前结点删除*/
else{
(5)
if(y ==s[i])s[i]=q;
else x→link=q;
}
}
for(i =0;i < n;i++)
{/*输出结果*/
if(s[i]==NULL)continue;
for(p=s[i];p!=NULL;){
printf(“\t%d”,p→data);
q=p→link;free(p);p=q;
}
printf(“\n”);
}
}

答案

参考答案:

解析:q→link=y 当前结点插入重新生成的i链表。

阅读理解

阅读理解。

     Fat and shy, Ben Saunders was the last kid in hid class picked for any sports team. "Football, tennis,

cricket- anything with a round ball, I was useless," he says now with a laugh. But back then he was the

one always made fun of in school gym chasses in Devonshire, England.

     It was a mountain bike he received for his 15th birthday that changed him. At first he went biking

alone in a nearby forest. Then he began to ride the bike along with a runner friend. Gradually, Saunders

set his mind on building up his body, increasing his speed and strength. At the age of 18, he ran his first

marathon.

     The following year, he met John Ridgway and was hired as an instructor at Ridgway' s School of

Adventure in Scotland, where he learned about Ridgway' s cold-water exploits, Greatly interested, Saunders

read all he could about North Pole explorers and adventures, then decided that this would be his future.

     In 2001, after becoming a skillful skier, Saunders started his first long-distance expedition (探险)

towards the North Pole. It took unbelievable energy. He suffered frostbite (冻疮), ran into a polar bear

and pushed his body to the limit, pulling his supply-loaded sled (雪橇) up and over rocky ice.

     Saunders has since become the youngest person to ski alone to the North pole, and he's skied more

of the North Pole by himself than any other British man. His old playmates would not believe the change.

     Next October, Saunders, 27, heads south from the coast of Antarctica to the South Pole and back,

a 2900-kilometre journey that has never been completed on skis.

1. What change happened to Saunders after he was 15 years old?

A. He became good at most sports.

B. He began to build up his body.

C. He joined a sports team.

D. He made friends with a runner.

2. The underlined word "exploits" (paragraph 3) is closest in meaning to ______.

A. journeys

B. researches

C. adventures

D. operations

3. Which of the following is the correct order of the events that happened to Saunders?

     a. He ran his first marathon.

    b. He skied alone in the North Pole.

    c. he rode his bike in a forest.

    d. He planned an adventure to the South Pole.

A. acdb

B. cdab

C. acbd

D. cabd

4. What does the story mainly tell us about Saunders?

A. He is a success in sports.

B. He is the best British skier.

C. He is Ridgway's favorite student.

D. He is a good instructor at school.

多项选择题