vb编程:求a=1+3+5+.+(2n-1)的值Private Sub Form_click()Dim a As IntegerDim i As IntegerDim n As Integern = InputBox("n=")For i = 1 To n a = a + 2 * n - 1Next iPrint "n="; n, "a="; aEnd Sub怎么不对呢?

来源:学生作业帮助网 编辑:作业帮 时间:2024/11/30 13:23:34
vb编程:求a=1+3+5+.+(2n-1)的值Private Sub Form_click()Dim a As IntegerDim i As IntegerDim n As Integern = InputBox(
x)+Kzgz)PXT[O<]{:jyڰ'(,$U!4I-(7>9'39[C%3W!QX3$5=D!l̂ <[%Mi@ !@@%*h+)ht R+J2N+QVQPJ1]R@zdgǓO|:qMR>ў+C$7႙1} F:X2@9KHfc ;ai@[oMdG7\

vb编程:求a=1+3+5+.+(2n-1)的值Private Sub Form_click()Dim a As IntegerDim i As IntegerDim n As Integern = InputBox("n=")For i = 1 To n a = a + 2 * n - 1Next iPrint "n="; n, "a="; aEnd Sub怎么不对呢?
vb编程:求a=1+3+5+.+(2n-1)的值
Private Sub Form_click()
Dim a As Integer
Dim i As Integer
Dim n As Integer
n = InputBox("n=")
For i = 1 To n
a = a + 2 * n - 1
Next i
Print "n="; n, "a="; a
End Sub
怎么不对呢?

vb编程:求a=1+3+5+.+(2n-1)的值Private Sub Form_click()Dim a As IntegerDim i As IntegerDim n As Integern = InputBox("n=")For i = 1 To n a = a + 2 * n - 1Next iPrint "n="; n, "a="; aEnd Sub怎么不对呢?
for 循环修改下
for i=1 to 2n-1 step 2
a=a+i
next i