求解,下面3道vb计算题(有关循环结构)方括号内是计算答案,望给出具体计算步骤和解释下计算题,谢谢
2个回答
展开全部
Private Sub Command1_Click()
x = 0
Print "x=" & x
Print "当 i = 0" & i & ", j = 0 " & j & "时,循环控制变量 j 的终止值 -1 小" + vbCrLf + "于初始值 0,故不运行循环体."
For i = 0 To 4
For j = 0 To i - 1
Print "当i = " & i & "," & "j = " & j; " 时,"
k = i + j - 1
Print "k = i + j - 1 = " & i & " + "; j & " - 1 = " & k & "."
If k Mod 2 = 0 Then
Print "因为 k Mod 2 = " & k & " Mod 2 = " & k Mod 2 & ","
t = x
x = x + k
Print "所以 x = x + k = " & t & " + " & k & " = "; x & "."
ElseIf k Mod 3 = 0 Then
Print "因为 k Mod 3 = " & k & " Mod 3 = " & k Mod 3 & " ,"
t = x
x = x + k - 2
Print "所以 x = x + k - 2 = " & t & " + " & k & " - 2 = "; x & "."
End If
Next j
Next i
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询