问题 填空题

阅读以下函数说明和C语言函数,将应填入 (n) 处的字句写在对应栏内。
[说明]
设一个环上有编号为0~n-1的n粒颜色不尽相同的珠子(每粒珠子颜色用字母表示,n粒珠子的颜色由输入的字符串表示)。从环上的某两粒珠子间剪开,则环上珠子形成一个序列然后按以下规则从序列中取走珠子:首先从序列左端取走所有连续的同色珠子;然后从序列右端在剩下的珠子中取走所有连续的同色珠子,两者之和为该剪开处可取走珠子的粒数。在不同位置剪开,能取走的珠子也不尽相同。
本程序所求的是在环上哪个位置剪开,按上述规则可取走的珠子粒数最多。程序中用数组存储字符串。例如:10粒珠子颜色对应字符串为“aaabbbadcc”,在0号珠子前剪开,序列为aaabbbadcc,从左端取走3粒a色珠子,从右端取走2粒c色珠子,共取走5粒珠子。若在3号珠子前剪开,即bbbadccaaa,共取走6粒珠子。
[C函数]
int count(char*s,int start,int end)
{inti,c=0,color=s[start],step=(start>end)-1:1;
for(i=start;s[i]==color;i+=step){
if(step>0 && i>end || (1) ) break;
(2) ;
}
return c;
}
void main()
{ char t,s[120];
int i,j,C,len,maxc,cut=0;
printf("请输入环上代表不同颜色珠子字符串:");
scanf("%s",s );
len=strlen(s);
for(i=maxc=0;i<len;i++){ /*尝试不同的剪开方式*/
c=count(s,0,len-1);
if(c<len) C+=count( (3) );
if(c>maxc){cut=i;maxc=c; )
/*数组s的元素循环向左移动一个位置*/
t=s[0];
for(j=1;i<len;i++) (4) ;
(5) ;
}
printf("在第%d号珠子前面剪开,可以取走%d个珠子.\n",cut,maxc);
}

答案

参考答案:step<0&&i<end (B) ++c (C) s,len-A,c (D) s[j-A]=s[j]

解析:(5) s[len-1]=t 依据取珠子个数最多的规则,count函数每次从左或从右取出相同颜色的珠子,因此从右到左的条件为step<0&&i<end,即(1)应填“step<0&&i<end”。当是同色珠子时,计数值加1,所以(2)填“++c”。从右到左计算时,函数count调用的实参次序为s,len-1,C。即(3)应填“s,len-1,c”。在尝试不同的剪开方式时,数组s的元素要循环向左移动一个位置,则(4)填“s[j-1]=s[j]”,(5)填“s[len-1]=t”。

完形填空

根据短文内容,从短文后的选项中选出能填入空白处的最佳选项。选项中有两项为多余选项。

Choosing the right job is probably one of the most important decisions we have to make in life, and it is frequently one of the hardest decisions we have to make. One important question that you might ask yourself is: “How do I get a good job?”___71___.

There are people who can answer an insignificant advertisement in the local paper and land the best job in the world; others write to all sorts of places all over the country, and never seem to get a reply at all. Still others believe that the in person, door-to-door approach is by far the best way to get a job; and then there are those who, through no active decision of their own, just seem to be in the right place at the right time. ___72____.He used to spend a lot of his free time down by the sea watching the tall ships, but never thinking that he might one day sail one of them. His father was a farmer, and being a sailor could never be anything for the boy but an idle dream. One day, on his usual wandering, he heard the captain of the ship complaining that he could not sail because one member of his crew was sick. Without stopping to think, the lad(少年)offered to take his place. ___73___.

__74__.If the lad had gone home to ponder(考虑) his decision for a week, he may have missed his chance. It is one thing to be offered an opportunity; it is another thing to take it and use it well.

Sometimes we hear stories about people who break all the rules and still seem to land plum jobs(美差). When you go for a job interview or fill out an application, you are expected to say nice things about the company to which you are applying. ___75___.And within a year this person had become general manger of the company.

A.This story also illustrates the importance of seizing an opportunity when it presents itself.

B.People find jobs in an infinite number of ways.

C.it’s almost impossible to find a good job by answering advertisement in newspapers

D.Take for example the young man who wanted to be a sailor.E. But there was one person who landed an excellent job by telling the interviewer all the company’s faults.

F. He spent the rest of his life happily sailing the ships he had always loved.

G. It is very important to seize an opportunity when it presents itself.

单项选择题