用BASIC或VB编写一个简单程序
S=a+aa+...+aaaa...a(最后一项有n个a)。如a=3,n=4,则S=3+33+333+3333,其中a和n由用户输入。...
S=a+aa+...+aaaa...a(最后一项有n个a)。如a=3,n=4,则S=3+33+333+3333,其中a和n由用户输入。
展开
2个回答
展开全部
Private Sub Form_Click()
Dim a, n As Integer
Dim i As Integer
Dim curn As Long
Dim S As Long
a = InputBox("请输入你要循环相加的数字", "提示")
n = InputBox("请输入你想要相加的个数", " 提示")
S = 0
curn = 0
For i = 1 To n
curn = CLng(String(i, a))
S = S + curn
Next
Me.Print S
End Sub
Dim a, n As Integer
Dim i As Integer
Dim curn As Long
Dim S As Long
a = InputBox("请输入你要循环相加的数字", "提示")
n = InputBox("请输入你想要相加的个数", " 提示")
S = 0
curn = 0
For i = 1 To n
curn = CLng(String(i, a))
S = S + curn
Next
Me.Print S
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询