设计一个程序框图求S=1+1/2+1/3+1/4+……+1/n之值,并写出程序
问题描述:
设计一个程序框图求S=1+1/2+1/3+1/4+……+1/n之值,并写出程序
答
n = Val(InputBox("请输入n=","输入"))
S = 0 :i = 1
Do
S = S + 1 / i
If Not (i < n) Then Exit Do
i = i + 1
Loop
MsgBox S,vbInformation,"输出"