早教吧作业答案频道 -->其他-->
编写程序求1+(1+2)+(1+2+3)+……前100项的和……vb用vb最好完整一点PrivateSubCommand1Click()Dimj,n,sAsIntegern=100s=0Forj=1Tons=s+f(j)NextPrint"S=1+(1+2)+(1+2+3)+…+(1+2+3+4+…
题目详情
编写程序 求1+(1+2)+(1+2+3)+……前100项的和……vb
用vb 最好完整一点
Private Sub Command1_Click()
Dim j,n,s As Integer
n = 100
s = 0
For j = 1 To n
s = s + f(j)
Next
Print "S=1+(1+2)+(1+2+3)+…+(1+2+3+4+…+100)=",s
End Sub
Function f(Bybal n As Integer) As Integer
Dim i,t As Integer
s = 0
For i = 1 To n
t = t + i
Next
f = t
End Function------这个是网络找的,输入vb一直有错
用vb 最好完整一点
Private Sub Command1_Click()
Dim j,n,s As Integer
n = 100
s = 0
For j = 1 To n
s = s + f(j)
Next
Print "S=1+(1+2)+(1+2+3)+…+(1+2+3+4+…+100)=",s
End Sub
Function f(Bybal n As Integer) As Integer
Dim i,t As Integer
s = 0
For i = 1 To n
t = t + i
Next
f = t
End Function------这个是网络找的,输入vb一直有错
▼优质解答
答案和解析
Private Sub Form_Click()
Dim i As Long,S As Long
For i = 1 To 100
S = S + CalcSum(i)
Next
Print S
End Sub
Function CalcSum(N As Long)
If N = 1 Then
CalcSum = 1
Else
CalcSum = CalcSum(N - 1) + N
End If
End Function
Dim i As Long,S As Long
For i = 1 To 100
S = S + CalcSum(i)
Next
Print S
End Sub
Function CalcSum(N As Long)
If N = 1 Then
CalcSum = 1
Else
CalcSum = CalcSum(N - 1) + N
End If
End Function
看了编写程序求1+(1+2)+(1...的网友还看了以下:
1、设p=a²+3ab+b²,Q=a²-3ab+b²,且p-[Q-2p-﹙-p-Q]+R=a²+2 2020-05-13 …
已知集合A=(Xlx平方+px+q=x)集合B=(Xl(x-1)方+p(x-1)+q=x+3)A= 2020-05-13 …
A.x×220+s×214+p×211+dB.{[(x)+s]+p}+dC.{[(x)+s]+p}× 2020-05-26 …
A.x×220+s×214+p×211+dB.((x)+x+p)×211+dC.(((x)+s)+p 2020-05-26 …
A.x*220+s*214+p*211+dB.(((x)+s)+p+dC.(((x)+s)+p)*2 2020-05-26 …
下列水量平衡方程表示正确的是( )A.h2+p+m-e-c=h1B.h1+p+M-e-c=h2C.h 2020-05-28 …
(本小题满分12分)已知圆M:(x+1)2+y2=1,圆N:(x-1)2+y2=9,动圆P与圆M外 2020-06-30 …
指出下列各式中哪些是代数式,哪些不是①2>1②S=1/2(a+b)h③a④9⑤2x+1⑥5a>1/ 2020-07-29 …
求特殊型的一元三次方程的求根公式啊!形如ax^3+bx+c=0X^3+pX+q=0(p、q∈R)卡 2020-08-02 …
1.㎡(p-q)-p+q;2.a(ab+bc+ac)-abc;3.x4-2y4-2x3y+xy3;4 2021-01-03 …