有哪位高手会VB 编程1^1+2^2+3^3+4^4+?………+〖100〗^100呦? 多谢多谢!!!

2024-12-15 16:58:57
推荐回答(3个)
回答1:

已验证,可直接得出结果,如果想得出中间过程,可以向循环内加入?a 或者s
前提是确定是i的i次方之和
Private Sub Command1_Click()
Dim s, a, i As Single
s = 0
Cls
For i = 1 To 100
a = i ^ i
s = s + a
Next i
Print s
End Sub

回答2:

dim i as long,s as long,t as long
s=0
for i=1 to 100
t=ixi
s=s+t
next i
我没验证过。不知道long的范围十分够,你也可以用double。

回答3:

Private Sub Command1_Click()
Dim a(1 To 30) As Integer
Randomize
For i = 1 To 30
a(i) = int(Rnd * 90 + 9)
Print a(i);
Next
End Sub