VB 执行下面程序,第一行输出结果是_,第二行输出结果是_.程序如下,答案为11,-20.请问,第二空-20怎么算Option ExplicitPrivate Sub Form_Click()Dim i As Integer,n As Integern=10For i = 1 To ni = i + 1n = n - iNext iPrint iPr
来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/21 09:10:03
VB 执行下面程序,第一行输出结果是_,第二行输出结果是_.程序如下,答案为11,-20.请问,第二空-20怎么算Option ExplicitPrivate Sub Form_Click()Dim i As Integer,n As Integern=10For i = 1 To ni = i + 1n = n - iNext iPrint iPr
VB 执行下面程序,第一行输出结果是_,第二行输出结果是_.程序如下,答案为11,-20.请问,第二空-20怎么算
Option Explicit
Private Sub Form_Click()
Dim i As Integer,n As Integer
n=10
For i = 1 To n
i = i + 1
n = n - i
Next i
Print i
Print n
End Sub
VB 执行下面程序,第一行输出结果是_,第二行输出结果是_.程序如下,答案为11,-20.请问,第二空-20怎么算Option ExplicitPrivate Sub Form_Click()Dim i As Integer,n As Integern=10For i = 1 To ni = i + 1n = n - iNext iPrint iPr
For i = 1 To 10
i = i + 1
n = n - i
Next i
这是循环,i=1时,i = i + 1=2,n = n - i=n-2
Next i // 使得i=3
进入循环,i=3时,i = i + 1=4,n = n - i=n-4
Next i // 使得i=5
进入循环,i=5时,i = i + 1=6,n = n - i=n-6
Next i // 使得i=7
进入循环,i=7时,i = i + 1=8,n = n - i=n-8
Next i // 使得i=9
进入循环,i=9时,i = i + 1=10,n = n - i=n-10
Next i // 使得i=11
循环结束
最终i=11,n=n-2-4-6-8-10=10-30=-20