问题 问答题

阅读以下说明和流程图,回答问题将解答填入对应栏。
[说明]
下面的流程图,用来完成求字符串t在s中最右边出现的位置。其思路是:做一个循环,以s的每一位作为字符串的开头和t比较,如果两字符串的首字母是相同的,则继续比下去,如果一直到t的最后一个字符也相同,则说明在s中找到了一个字符串t;如果还没比较到t的最后一个字符,就已经出现字符串不等的情况,则放弃此次比较,开始新一轮的比较。当在s中找到一个字符串t时,不应停止寻找(因为要求的是求t在s中最右边出现位置),应先记录这个位置pos,然后开始新一轮的寻找,若还存在相同的字符串,则更新位置的记录,直到循环结束,输出最近一次保存的位置。如果s为空或不包含t,则返回-1。
注:返回值用pos表示。
[*]
[问题]
将流程图的(1)~(5)处补充完整。

答案

参考答案:pos=-1; (2) s[i]!=’\0’; (3) s[j]=t[k]; (4) k>0; (5) pos=i;

解析:
本试题考查流程图。
题目中说明,如果s中不包含t,则返回-1,由流程图可以看出,如果(2)的条件不满足,流程图会直接跳到最后Returnpos,所以,在开始进行查找之前,就要先将pos置-1,所以(1)填入“pos=-1”。循环开始,(2)保证的条件应该是s[i]不是空的,即(2)填入“s[i]!=’\0’”。下面就开始进行比较,由于要输出的是最右边出现的位予,所以当第一次比较到相同的字符时不能输出,只要暂时把保存着,即(5)填入“pos=i”,然后进行下一次循环,当又出现相同的字符串时,就将pos的值更新,如果一直到最后都没有再次出现相同的字符串,就把pos输出。当比较到第一个相同的字符时,要继续比较下去,看是不是t和s的每一个字符全相同,所以(3)应填入“s[j]=t[k]”。在什么情况下能说明t和s完全相同呢就是当t一直比较到最后一个字符即空格时,并且k大于0(因为如果k等于0,则说明第一个字母就不相同,根本没有开始比较),所以(4)应填入“k>0”。

阅读理解

Ever since I was a little child, my parents have told me to be honest because it is the right thing to do. As I got older, I realized something very important. If just once you are deceitful and tell a lie, it will greatly change people’s opinions about you and their way of acting toward you. When you tell a lie, you lose that person’s trust forever or have to work your whole life to get it back.

It is my personal goal to achieve great things in life and honesty(诚实) will sure help me get there. For me right now losing somebody’s trust would be a truly terrible thing. My parents would be stricter on the things they let me do and the places that they used to let me go to. My friends would never again tell me a secret or believe many things I told them. Whatever you do for a living or wherever you live, honesty is something very important.

Honesty gets you much higher in life while telling a lie can make you get into more problems. I can already tell that the great people I have met so far are all honest people.

I hope that I’ll never fall into a situation where I’ll lie. Honesty is just as important to me as my family. Already, I know it is something that will improve my future and my relationship with all people. It is something about myself that I hope never to lose no matter what happens. Honesty will help me no matter whether I’m at school, home or just hanging out with friends. It is something that I hope my children will also have and value.

小题1:The underlined word “deceitful” in Paragraph 1 probably means “________”.

A.strange

B.lucky

C.sad

D.dishonest小题2:Which of the following statements is NOT true?

A.Being honest is very important and helpful.

B.The writer was taught to be honest when he was young.

C.The writer thinks it doesn’t matter if he tells a lie.

D.To win others’ trust is not easy.小题3:What does the writer want to tell us in the passage?

A.Ways to be honest.

B.Honesty is very important for us to achieve our goals.

C.True friendship is based on(以…为基础) others’ trust.

D.Honesty can make us live a happy life.小题4:How is the text mainly developed?

A. By making comparisons.(作比较)       B. By showing facts.

B.By explaining reasons.               D. By giving examples.

单项选择题 A1型题