VB s大于1000的最小正数,其中S=1+2+3+...+N 代码是什么?

2024-11-24 04:34:27
推荐回答(3个)
回答1:

Function s(n As Integer) As Integer 'n为最小正数要大于的数,如题取 s(1000)=1035
Dim i As Integer
s = 0
For i = 1 To 32767
s = s + i
If s > n Then
Exit For
End If
Next
End Function

回答2:

'VB s大于1000的最小正数,其中S=1+2+3+...+N 代码是什么
Dim N As Integer
Dim S As Integer
N = 1
S = 0
Do While S < 1000
S = S + N
N = N + 1
Loop
N = N - 1

回答3:

Dim m As Integer,n As Integer
N = 1
s= 0
Do While n < 1000
s = s + N
N = N + 1
Loop