问题 问答题 简答题

结构体数据作为参数在函数间传递有哪几种方式?请指出它们的异同点。

答案

参考答案:

结构体作为参数在函数之间进行传递主要有下 * * 种方式:

复制传递方式:把调用函数中结构体实参的值复制给被调用函数的形参构体。

地址传递方式:将调用函数中实参结构体的地址传递给被调用函数形参的结构体指针。

引用方式:被调用函数的形参应该说明为引用结构体变量形式。实际上,它是为实参结构化起一个别名。

另外,还可以通过全局变量的方式在函数间进行数据传递,但这种方式不好,增加函数之间的耦合性。

地址传递方式要比复制方式效率高。结构体复制传递方式需要对实参做一个备份,它把一个结构体变量作为参数传递,但要将结构体全部成员值一个一个传递,费时间又费空间,开销大。如果结构体的成员较多,则程序运行效率会大大降低,而采用地址传递方式将结构体变量的地址作为函数参数比较好,能提高运行效率。复制传递方式不影响调用函数实参的数值,而地址传递方式有可能影响实参的数值。

单项选择题 A1/A2型题
阅读理解

阅读理解。

     Although many Chinese students say that their knowledge of English grammar is good, most would admit

that their spoken English is poor. Whenever I speak to a Chinese student they always say, "My spoken English

is poor." However, their spoken English does not have to remain "poor"! I would like to suggest that there may

be some reasons for their problems with spoken English.

     First, they fail to find suitable words to express themselves due to a limited vocabulary. Obviously the better

answer is to expand their vocabulary. However, you can speak with a limited vocabulary, if your attitude is

positive. Others will follow you as long as you use the words that you know.

     Second, they are afraid of making mistakes. Sometimes they make mistakes when they are speaking because

they are shy and nervous. Yet students should remember that their goal should be FLUENCY NOT ACCURACY.

Your aim in writing is to be accurate following the rules for grammar and using the right words and spelling the

m correctly. However, in speaking your aim is fluency. You want to get your message across,that is, to talk to

someone in English, as quickly and as well as you can, even though sometimes you may use a wrong word or

tense, but it doesn't matter because the person you are speaking to will understand you and make allowances for

any mistakes he hears.

     The third reason is that not enough attention is paid to listening. You have one mouth but two ears! All that

hearing was necessary for you to start speaking.

     Forth, most Chinese students are reactive rather than proactive language learners. Instead of actively seeking

out opportunities to improve their spoken English they passively wait for speaking opportunities to come to them

and wonder why their English always remains poor. If you have this proactive outlook, then you will see English

opportunities wherever you go.

     If you do not use your English beyond the classroom you will forget what English you know. Remember:

USE IT OR LOSE IT! You can learn how to speak English better by speaking English more.

1. What is most probably the writer's purpose in writing the passage? [ ]

A. To improve your reading.

B. To improve your listening.

C. To improve your spoken English.

D. To improve your vocabulary.

2. We can learn from the third paragraph that _____. [ ]

A. Fluency is more important than accuracy.

B. It doesn't matter to make mistakes when we use English.

C. In order to get our message across we should speak cautiously.

D. Feeling shy and nervous can lead to errors.

3. Which of the following is true about Chinese students?[ ]

A. They are passive learners.

B. They are active in looking for a chance to practice their oral English.

C. They tend to wait for somebody to speak to them in English.

D. They speak English slowly without mistakes.

4. The last paragraph is close to the meaning of "_____". [ ]

A. More hurry, less speed

B. Better late than never

C. Silence is gold

D. Practice makes perfect

5. The text is most probably taken from a _____. [ ]

A. teacher's diary

B. report on study

C. sports newspaper

D. movie magazine