1+2/1+3/1+.+n/1 2/1+4/1+.+2n/1 用VB编码编程.

来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/26 20:17:59
1+2/1+3/1+.+n/12/1+4/1+.+2n/1用VB编码编程.1+2/1+3/1+.+n/12/1+4/1+.+2n/1用VB编码编程.1+2/1+3/1+.+n/12/1+4/1+.+2

1+2/1+3/1+.+n/1 2/1+4/1+.+2n/1 用VB编码编程.
1+2/1+3/1+.+n/1 2/1+4/1+.+2n/1 用VB编码编程.

1+2/1+3/1+.+n/1 2/1+4/1+.+2n/1 用VB编码编程.
2/1?是你写错了还是我看错了?确定是一分之二?不是二分之一?那不就等于2嘛?
1+2/1+3/1+.+n/1 = 1+2+3+.+n
代码:
Dim i As Long,n As Long,s As Long
n = Val(Inputbox("请输入n值"))
For i = 1 To n
s = s + i
Next
MsgBox "1+2/1+3/1+.+n/1 的值是" & s
2/1+4/1+.+2n/1 = 2+4+.+2n
代码:
Dim i As Long,n As Long,s As Long
n = Val(Inputbox("请输入n值"))
For i = 2 To 2 * n Step 2
s = s + i
Next
MsgBox "2/1+4/1+.+2n/1 的值是" & s