2个回答
展开全部
Option Explicit
Private Sub Form_Click()
Dim SymbolCount As Integer '输出符号的最大个数,即最底层字母或符号的个数
Dim SpaceCount As Integer '左边的空格数
Dim OutPutSpace As String '保存要输出的左边的空格
Dim OutPutSymbol As String '保存要输出的字符和字符间的空格
Dim i, j As Integer
SymbolCount = 5 '设定金字塔的高度为5层,最底层输出的符号也刚好是5个
SpaceCount = (SymbolCount * 2 - 1) / 2 '左边空格数的初始值等于底层输出字符+字符间空格的个数的一半
OutPutSymbol = "*"
OutPutSpace = ""
For i = 1 To SpaceCount '计算第一行左边所需要输出的空格数目
OutPutSpace = OutPutSpace & " " '累加空格数目
Next i
For i = 1 To SymbolCount
Print OutPutSpace & OutPutSymbol '输出计算后得出的这行的结果
If SpaceCount > 0 Then
SpaceCount = SpaceCount - 1
End If
OutPutSpace = Left(OutPutSpace, SpaceCount) '左边空格,下一行比上一行少一个空格
OutPutSymbol = OutPutSymbol & " *" '下一行比上一行多一个空格和一个星号
Next i
End Sub
2016-05-11
展开全部
Dim a, b, c, d, 星号MaX
Private Sub Form_Load()
Me.Caption = "单击窗体后开始"
a = 0
b = ""
c = 0
星号MaX = 5
End Sub
Private Sub Form_Click()
b = ""
Me.Cls
For a = 1 To 星号MaX
b = b & "*" & " "
d = ""
For c = 1 To (星号MaX - a)
d = d & " "
Next
Print d & b
Next
End Sub
Private Sub Form_Load()
Me.Caption = "单击窗体后开始"
a = 0
b = ""
c = 0
星号MaX = 5
End Sub
Private Sub Form_Click()
b = ""
Me.Cls
For a = 1 To 星号MaX
b = b & "*" & " "
d = ""
For c = 1 To (星号MaX - a)
d = d & " "
Next
Print d & b
Next
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询