VB编程 累加器的问题 已知S=1+2+3·······+N,找出一个最大的整数N,使得S<30000,编程解决。

没听讲的某人在这感激不尽了TVT
2024-12-15 16:13:37
推荐回答(4个)
回答1:

dim s as long,n as integer
For n=1 to 30000
if s +n >=30000 Then Exit For
s=s+n
Next
Msgbox "最大数是" & n

回答2:

n^2+n<60000
求deta算呗

回答3:

Private Sub Command1_Click()
Do
n = n + 1
s = s + n
Loop until s>=30000
Print n - 1
End Sub

回答4:

dim i as long,
dim s as long,
dim N as long
do while (i>=1 and i<=N)
s=0
s=s+i
i=i+1
next j
loop
do while (s<30000)
print N
loop