单选题 VB
题号 #2273194

在窗体上面1个名称为Command1的命令按钮,然后编写下列事件过程
Option Base 1
Private Sub,Command1 Click(  )
Dim a(5,5)ks Integer
For i=1 To j
For j=1 To 5
a(i,j)=(i+j)*5\10
Next j
Next i
S=0
For i=1 To j
s=s+a(i,i)
Next i
Print s
End Sub
程序运行后,单击命令按钮,输出结果是(  )。

进入在线模考

参考答案

A

答案解析

A。【解析】程序首先是利用两层For循环给数组进行赋值,其规律是:第一行,a(1,1)=1,a(1,2) =1,a(1,3)=2,a(1,4)=2,a(1,5)=3;第二行,a(2,1)=1,a(2,2)=2,a(2,3)=2,a(2,4)=3,a(2,5) =3;第三行,a(3,1)=2,a(3,2)=2,a(3,3)=3,a(3,4)=3,a(3,5)=4;……第五行,a(5,1)=3,a(5,2) =3,a(5,3)=4,a(5,4)=4,a(5,5)=5。可知正对角线上的是1、2、3、4、5。题中的S就是计算正对角线上的和。故应选择A。

你可能感兴趣的试题

A.Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii==13 Then
'回车符的ASCIl码是13
a=Val(Text1)
If a>=0 Or a<=100 Then
Text2.SetFocus
Else
Text1.SetFocus:MsgBox("分数错")
End If
End If
End Sub
B.Private Sub Textl—KeyPress(KeyAscii As Integer)
If KeyAseii=13 Then
'回车符的ASCIl码是13
a=Val(Text1)
If a>=0 And a<=100 Then
Textl.SetFocus
Else
Text2.SetFocus:MsgBox("分数错")
End If
End If
End Sub
C.Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii=13 Then
'回车符的ASCII码是13
a=Val(Text1)
If a<0 And a>100 Then
Text2.SetFocus
Else
Text1.SetFocus:MsgBox("分数错")
End If
End If
End Sub
D.Private Sub Text1_KeyPress(KeyAscii As Integer)
If KevAscii=13 Then
'回车符的ASCII码是13
a=Val(Textl)
If a>=0 Aad a<=100 Then
Text2.SetFocus
Else
Text1.SetFocus:MsgBox("分数错")
End If
End If
End Sub
A.各模块应包括尽量多的功能
B.各模块的规模应尽量大
C.各模块之间的联系应尽量紧密
D.模块内具有高内聚度、模块间具有低耦合度
找试题 · 找答案 · 找资料 在线模考