VB s大于1000的最小正数,其中S=1+2+3+...+N 代码是什么? 5
3个回答
展开全部
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
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
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
'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
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
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Dim m As Integer,n As Integer
N = 1
s= 0
Do While n < 1000
s = s + N
N = N + 1
Loop
N = 1
s= 0
Do While n < 1000
s = s + N
N = N + 1
Loop
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询