问题 填空题

阅读以下说明和C代码,将应填入 (n) 处的字句写在对应栏内。

[说明]

下面程序用来将打乱的单词还原为原来的次序,比如将rty还原为try。单词的原来次序存储于wordlist.txt文件中,原则上可用穷举法(rty对应的穷举为:rty、ryt、try、tyr、ytr、yrt),但考虑到破译速度,采用如下方法。

注意到单词列表中不存在组成字符完全相同的单词(如Hack12与Hack21包含完全相同的字符),因此将单词中的字符进行重组再进行比较,例如,try单词重组为rty(按ASCⅡ码顺序),这样不管打乱的单词是什么顺序,只要是由r、t、y三个字母组成的均破译为try,大大提高破译速度。程序中借助二叉排序树以进一步提高查找效率,二叉排序树左子树(如果有)上的节点对应的值均小于根节点的值,右子树(如果有)上的节点对应的值均大于根节点的值。

函数中使用的符号定义如下:

#define NumberofWords 1275//单词总数

#define MaxLength 10//最长单词所含字符数

char WordList[NumberofWords][MaxLength];//存储单词列表

int cmp(Node *q,Node *p);//q与p比较。p小,返回负值;P大返回正值:相等,返回0

typedef struct Node(//二叉树节点

char *eleLetters;//重组后的字符串

int index;//对应单词表中的下标

struct Node *lChiId,*rChiid;//左右子节点

Node;

[C代码]

void reCompose(Node *p,char *temp)

//重纰,亦即将temp字符串中的字符升序排序,存储于p节点中

//采用直接插入排序法

char c;

strcpy(p->eleLetters,temp);//

int len=strlen(temp);

int i,j,k;

for(i=0;i<len-1;i++)

k=i;

for(j=i+1;j<lan;j++)

if(p->eleLetters[j]<P->eleLetters[k])k=J;

if( (1) )

C=P->eleLetters[i];

P->eleLetters[i]=P->eleLetters[k];

P->eleLetters[k]=c;

//if

//for

int find(Node &root,char *temp)

//在二叉排序树root中查找与temp匹配的单词。

//若匹配返回相应单词在WordList中下标;若查找失败,返回-1

Node *P,*q;

int flag;

P= (2) ;//临时存储

reCompose(p,temp);//将temp重组

q=&root;

while((flag= (3) )&&q !=NULL)

if(flag<0)//搜索左子树

q=q->lChiid;

else(//搜索右子树

q=q->rChild;

//while

if(flag==0)//找到匹配的,保存下标

return (4)

if( (5) )//查找失败

printf("cant unscramble the following word:%s",temp);;

return -1;

(2)处填()。

答案

参考答案:(Node *)malloc(sizeof P)

多项选择题
阅读理解

Elephants have four distinct personalities that help their herd survive in the African bush, scientists have found. 

With their grey skin, mournful eyes and slow heavy pace, you could be forgiven for thinking elephants are uniformly melancholy(忧郁的) creatures. But scientists have now discovered the largest living land animals have personalities to match their size.

In a new study of African elephants, researchers have identified four distinct characters that are common in a herd – the leaders, the gentle giants, the playful rogues(小淘气) and the reliable plodders (辛勤工作的人).

Each of the types has developed to help the giant mammals survive in their harsh environment and is almost unique in the animal kingdom, according to the scientists.

Professor Phyllis Lee and her colleague Cynthia Moss studied a herd of elephants in the Amboseli National Park in Kenya known as the EB family — famous for their matriarch Echo before she died in 2009.

Using data collected over 38 years of watching this group, the researchers analyzed them for 26 types of behavior and found four personality features tended to emerge.

The strongest personality to emerge was that of the leader. Unlike other animals, where leadership tends to be won by the most dominant and aggressive individual, the elephants instead respected intelligence and problem solving in their leader. Echo, the matriarch and oldest in the group, her daughter Enid, and Ella, the second oldest female, all emerged as leaders.

The playful elephants tended to be younger but were more curious and active. Eudora, a 40-year-old female in the herd, seemed to be the most playful, consistently showing this feature throughout her life while playfulness in some of the other elephants declined with age.

Gentle elephants, which included two 27-year-old females Eleanor and Eliot, touched and rubbed against others more than the others.

Those that were reliable tended to be those that were most consistent at making good decisions, helped to care for infants in the herd and were calm when faced with threats. Echo and her youngest daughter Ebony seemed to be the most reliable.

Professor Lee said that elephants with these features tended to be the most socially integrated in the group while those who tended to be less reliable and pushy were more likely to split from the herd.

小题1:From the passage we get to know that ________.

A.the researchers reached their conclusion by analyzing the data

B.the research centered on the 26 types of behavior of the matriarch

C.the scientists conducted the research by comparing elephants with other animals

D.professor Phyllis Lee and her colleague spent nearly 38 years tracking the herd小题2:According to the new findings of the scientists, ________.

A.playfulness of an elephant will always decline with age

B.those elephants which are caring and wise are most reliable

C.each elephant can be matched with only one of the four personalities

D.once becoming a member of a herd, an elephant will never split from it小题3:In the EB family Echo and Eudora are ________.

A.mother and daughter

B.two oldest females

C.the gentlest ones

D.leader and member