为这个而VB看序为
答案:1 悬赏:30 手机版
解决时间 2021-11-20 10:55
- 提问者网友:战皆罪
- 2021-11-20 01:46
为这个而VB看序为
最佳答案
- 五星知识达人网友:躲不过心动
- 2021-11-20 03:19
Sub main()
Dim k%, n%, t%, p2%, p3%, a&, b&, s&, f&(100)
n = InputBox("n=")
a = 2: b = 3
For k = 1 To n
If a < b Then
f(k) = a: a = a * 2
t = 2: p2 = p2 + 1
Else
f(k) = b: b = b * 3
t = 3: p3 = p3 + 1
End If
s = s + f(k)
Next
Debug.Print "第"; n; "项为:"; f(n);
If t = 2 Then
Debug.Print "(2^"; p2; ")"
Else
Debug.Print "(3^;p3"; ")"
End If
Debug.Print "前"; n; "项和为:"; s
End Sub
Dim k%, n%, t%, p2%, p3%, a&, b&, s&, f&(100)
n = InputBox("n=")
a = 2: b = 3
For k = 1 To n
If a < b Then
f(k) = a: a = a * 2
t = 2: p2 = p2 + 1
Else
f(k) = b: b = b * 3
t = 3: p3 = p3 + 1
End If
s = s + f(k)
Next
Debug.Print "第"; n; "项为:"; f(n);
If t = 2 Then
Debug.Print "(2^"; p2; ")"
Else
Debug.Print "(3^;p3"; ")"
End If
Debug.Print "前"; n; "项和为:"; s
End Sub
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯