展开全部
1、具体实现星号三角形的代码如下:
Public Function sanjiaoxing(ByVal num As Integer) As String
Dim i, j As Integer
Dim st As String
st = ""
Dim m As Integer
If (num Mod 2 = 0) Then
sanjiaoxing = ""
End If
'输出上三角形
For i = 1 To (num + 1) \ 2
For j = 1 To (num + 1) / 2 - i
st = st & " "
Next
For j = 1 To 2 * i - 1
st = st & "*"
Next
st = st & vbCrLf
Next
sanjiaoxing = st
End Function
Private Sub Form_Click()
Print sanjiaoxing(11)
End Sub
Public Function sanjiaoxing(ByVal num As Integer) As String
Dim i, j As Integer
Dim st As String
st = ""
Dim m As Integer
If (num Mod 2 = 0) Then
sanjiaoxing = ""
End If
'输出上三角形
For i = 1 To (num + 1) \ 2
For j = 1 To (num + 1) / 2 - i
st = st & " "
Next
For j = 1 To 2 * i - 1
st = st & "*"
Next
st = st & vbCrLf
Next
sanjiaoxing = st
End Function
Private Sub Form_Click()
Print sanjiaoxing(11)
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |