求用VB写出:S=1+3+5+7+....+999的值(要详细过程)

2024-12-29 17:02:33
推荐回答(4个)
回答1:

什么是VB啊,你们有没有教等差数列啊。有公式可以算的:S=na [n*(n 1)]/2,a是第一个数,n是项数,这题是500吧

回答2:

Private Sub Command1_Click()
For i = 1 To 999 Step 2
Sum = Sum + i
Next i
Print Sum
End Sub

回答3:

Dim a As Single, i As Single
i = (999 + 1) / 2 * (1 + 999)
MsgBox i

回答4:

Dim s As Integer,i As Integer
s=0
i=1
Do
s=s+i
i=i+2
Loop Until i>999
Print "S=1+3+5+7+...+999=";s