问题 单项选择题

在窗体上画一个命令按钮和一个标签,其名称分别为Command1和Label1,然后编写如下代码:
Sub s(x As Integer, y As Integer)
Static z As Integer
y=x*x+z
z=y
End Sub
Private Sub Command1 Click()
Dim i As Integer, z As Integer
m=0
z=0
For i=1 To 3
S i, Z
m=m+z
Next i
Labell. Caption=Str(m)
End Sub
程序运行后,单击命令按钮,在标签中显示的内容是( )。

A.50

B.20

C.14

D.7

答案

参考答案:B

解析: Static语句在过程级别中使用,用于声明变量并分配存储空间,在整个代码运行期间都能保留使用Static语句声明的变量的值。参数传递时默认为地址传递,如果实参为常量或者形参加上ByVal关键字说明,则为传值传递。本题中过程s的参数x和y均为地址传递,在过程s中有一个静态变量z。在本题中要注意过程s中的变量z和命令按钮的单击事件中的变量z都是各自过程的局部变量,这两个变量并不是同一个变量。在命令按钮的Click事件中,分三次使用循环调用了过程s,并且将调用s后改变的z值累加到变量m中,最后m即为所求。在第一次循环中,i的值为1,z的值为0,通过调用过程s改变了形参y的值为1并且随之影响了实参z的值为1,同时过程s中的静态变量z的值也为1,在m中累加了1;在第二次循环中,i的值为2,z的值为1,通过调用过程s改变了形参y的值为5并且随之影响了实参z的值为5,同时过程s中的静态变量z的值也为5,在m中累加了5;在第三次循环中,i的值为3,z的值为5,通过调用过程s改变了形参v的值为14并且随之影响了实参z的值为14,在m中累加了14。最终m的值为1+5+14=20。

阅读理解

Lisa was running late. Lisa,25,had a lot to do at work,plus visitors on the way: her parents were coming in for Thanksgiving from her hometown. But as she hurried down the subway stairs,she started to feel uncomfortably warn. By the time she got to the platform,Lisa felt weak and tired--maybe it hadn’t been a good idea to give blood the night before,she thought. She rested herself against a post close to the tracks.

Several yards away,Frank,43,and his girlfriend,Jennifer,found a spot close to where the front of the train would stop. They were deep in discussion about a house they were thinking of buying.

But when he heard the scream,followed by someone yelling,“Oh,my God,she fell in!” Frank didn’t hesitate. He jumped down to the tracks and ran some 40 feet toward the body lying on the rails. “No! Not you! ”his girlfriend screamed after him.

She was right to be alarmed. By the time Frank reached Lisa,he could feel the tracks shaking and see the light coming. The train was about 20 seconds from the station.

It was hard to lift her. She was just out. But he managed to raise her the four feet to the platform so that bystanders could hold her by the grins and drag her away from the edge. That was where Lisa briefly regained consciousness,felt herself being pulled along the ground,and saw someone else holding her purse.

Lisa thought she’d been robbed. A woman held her hand and a man gave his shirt to help stop the blood pouring from her head. And she tried to talk but she couldn’t,and that was when she realized how much pain she was in.

Police and fire officials soon arrived,and Frank told the story to an officer. Jennifer said her boyfriend was calm on their 40-minute train ride downtown—just as he had been seconds after the rescue,which made her think about her reaction at the time. “I saw the train coming and 1 was thinking he was going to die,”she explained.

41. What was the most probable cause for Lisa’s weakness?

A. She had run a long way.

B. She felt hot in the subway.

C. She had done a 1ot of work.

D. She had donated blood the night before.

42. Why did Jennifer try to stop her boyfriend?

A. Because they would miss their train.

B. Because he didn’t see the train coming.

C. Because she was sure Lisa was hard to lift.

D. Because she was afraid the train would kill him.

43. How did Frank save Lisa?

A. By lifting her to the platform.

B. By helping her rise to her feet.

C. By pulling her along the ground.

D. By dragging her away from the edge.

44. When did Lisa become conscious again?

A. When the train was leaving.

B. After she was back on the platform.

C. After the police and fire officials came.

D. When a man was cleaning the blood from her head.

45. The passage is intended to _____________

A. warn us of the danger in the subway

B. show US how to save people in the subway

C. tell US about a subway rescue

D. report a traffic accident

名词解释