问题 填空题

下面是一个JavaApplet程序,请将程序补充完整使它的功能为计算数组各元素的平均值。 import java.applet.Applet; import java.awt.*; public class Exam extends Applet{ public void paint(Graphics g){ int a[ ]={1,3,5,7,9,10}; int total=0; float ave; for(int i=0; i<A.length;i++)total+=a[i]; ave=total/ g.drawstring("ave="+ave,30,60); } }

答案

参考答案:a.length

解析: 本题考查Java的循环结构。for循环的一般格式为: for(初始化部分;终止条件判断部分;迭代部分) { //循环体; } 说明如下:for循环开始时,首先执行初始化操作,然后判断终止条件是否满足,如果满足,则执行循环体中的语句,最后执行迭代部分。完成一次循环后,重新判断终止条件。为了计算数组各元素和的平均值,第1步是先将各元素累加起来,用for语句很容易实现,得到的和放在total里,第2步是将这个和除以总共元素的个数,重新判断终止条件。

单项选择题
单项选择题

Attempts to understand the relationship between social behavior and health have their origin in history. Dubos (1969) suggested that primitive humans were closer to the animals (1) they, too, relied’upon their instincts to stay healthy. Yet some primitive humans (2) a cause and effect relationship between doing certain things and alleviating (3) of a disease or (4) the condition of a wound. (5) there was so much that primitive humans did not (6) the functioning of the body, magic became an integral component ofthe beliefs about the causes and cures of heath (7) Therefore it is not (8) that early humans thought that illness was caused (9) evil spirit. Primitive medicines made from vegetables or animals were invariably used in combination with some form of ritual to (10) harmful spirit from a diseased body.

One of the. earliest (11) in the Western world to formulate principles of health care based upon rational thought and (12) of supernatural phenomena is found in the work of the Greek physician Hippocrates. The writing (13) to him has provided a number of principles underiying modern medical practice. One of his most famous (14) , the Hippocratic Oath, is the foundation of contemporary medical ethics.

Hippocrates also argued that medical knowledge should be derived from a (15) of the natural science and the logic of cause and effect relationships. In this (16) thesis, On Air, Water, and Places, Hippocrates pointed out that human well-being is (17) by the totality of environmental (18) : living habits or lifestyle, climate, geography of the land, and the quality of air, and food. (19) enough, concerns about our health and the quality of air, water, and places are (20) very much written in twentieth century.

12()

A.foundation

B.rejection

C.integration

D.acceptance