问题 单项选择题

编制一个好的程序,要确保它的正确性和可靠性的同时,还应强调良好的编程风格。在选用标识符的名字时应考虑( )。

A.名字长度越短越好,以减少源程序的输入量

B.多个变量共用一个名字,以减少变量名的数目

C.选择含义明确的名字,以正确提示所代表的实体

D.尽量用关键字作名字,以使名字标准化

答案

参考答案:C

解析: 本题涉及编程风格,考生应该掌握一些基本的良好编程风格。标识符的名字应能反映它所代表的实际东西,应有一定实际意义。名字不是越长越好,应当选择精炼的意义明确的名字。必要时可使用缩写名字,但这时要注意缩写规则一致,并且要给每一个名字加注释。同时,在一个程序中,一个变量只应用于一种用途。

单项选择题
单项选择题

All animals must rest, but do they really sleep as we know it The answer to this question seems obvious. If an animal regularly stops its activities and stays quiet and unmoving—if it looks as though it is sleeping—then why not simply assume that it is in fact sleeping But how can observers be sure that an animal is sleeping

They can watch the animal and notice whether its eyes are open or closed, whether it is active or lying quietly, and whether it responds to light or sound. These factors are important clues, but they often are not enough. Horses and cows, for example, rarely close their eyes, and fish and snakes cannot close them. Yet this does not necessarily mean that they do not sleep. Have you ever seen a cat dozing with an eye partly open Even humans have occasionally been observed to sleep with one or both eyes partially open. Animals do not necessarily lie down to sleep either. Elephants, for example, often sleep standing up, with their tusks resting in the fork of a tree. Finally, while "sleeping" animals often seem unaware of changes in the sounds and light and other stimuli around them, that does not really prove they are sleeping either.

Observations of animal behavior alone cannot fully answer the question of whether or not animals sleep. The answers come from doing experiments in "sleep laboratories" using a machine called the electroencephalograph (EEC). The machine is connected to animals and measures their brain signals, breathing, heartbeat, and muscle activity. The measurements are different when the animals appear to be sleeping than when they appear to be awake. Using the EEC, scientists have confirmed that all birds and mammals studied in laboratories do sleep. There is some evidence that reptiles, such as snakes and turtles, do not truly sleep, although they do have periods of rest each day, in which they are quiet and unmoving. They also have discovered that some animals, like chimpanzees, cats, and moles (who live underground), are good sleepers while others, like sheep, goats, and donkeys, are poor sleepers. Interestingly, the good sleepers are nearly all hunters with resting places that are safe from their enemies. Nearly all the poor sleepers are animals hunted by other animals: they must always be watching for enemies, even when they are resting.

Animals that are good sleepers()

A. need to have a good sleep after they have exhausted themselves by getting rid of hunting animals

B. need to have a good sleep after they get tired from hunting other animals

C. are all mammals

D. almost always have a safe resting place