VB输出菱形图形 20
55455434554323455432123455432345543455455如何输出此图形...
5
545
54345
5432345
543212345
5432345
54345
545
5
如何输出此图形 展开
545
54345
5432345
543212345
5432345
54345
545
5
如何输出此图形 展开
5个回答
展开全部
Private Sub Command1_Click()
For j = 5 To 2 Step -1
Print Tab(3 * j);
For i = 5 To j Step -1
Print i;
Next
For k = j + 1 To 5
Print k;
Next
Next
For j = 1 To 5
Print Tab(3 * j);
For i = 5 To j Step -1
Print i;
Next
For k = j + 1 To 5
Print k;
Next
Next
End Sub
第二种
Private Sub Command2_Click()
For j = 5 To 2 Step -1
Print Tab(5 + j);
For i = 5 To j Step -1
b = b & i
Next
For k = j + 1 To 5
b = b & k
Next
Print b
b = ""
Next
For j = 1 To 5
Print Tab(5 + j);
For i = 5 To j Step -1
b = b & i
Next
For k = j + 1 To 5
b = b & k
Next
Print b
b = ""
Next
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Option Explicit
Private Sub Command1_Click()
Dim h As Integer
Dim i As Integer
Dim j As Integer
Dim s As String
Dim Dt As Integer
Dim t As Integer
Dim k As Integer
Dim p As Integer
Dim YesNo As Boolean
p = 0
h = Val(InputBox("输入一个[1,9]之间的正整数!"))
For i = 1 To 2 * h - 1
t = Abs(h - i)
If t > 0 Then
s = Space(t)
Else
s = ""
End If
If Not YesNo Then
p = p + 1
Else
p = p - 1
End If
If p > h Then
YesNo = True
p = p - 2
End If
Dt = h
k = 0
For j = 1 To 2 * p - 1
s = s & CStr(Dt)
k = k + 1
If k < p Then
Dt = Dt - 1
Else
Dt = Dt + 1
End If
Next j
Print s
Next i
End Sub
Private Sub Command1_Click()
Dim h As Integer
Dim i As Integer
Dim j As Integer
Dim s As String
Dim Dt As Integer
Dim t As Integer
Dim k As Integer
Dim p As Integer
Dim YesNo As Boolean
p = 0
h = Val(InputBox("输入一个[1,9]之间的正整数!"))
For i = 1 To 2 * h - 1
t = Abs(h - i)
If t > 0 Then
s = Space(t)
Else
s = ""
End If
If Not YesNo Then
p = p + 1
Else
p = p - 1
End If
If p > h Then
YesNo = True
p = p - 2
End If
Dt = h
k = 0
For j = 1 To 2 * p - 1
s = s & CStr(Dt)
k = k + 1
If k < p Then
Dt = Dt - 1
Else
Dt = Dt + 1
End If
Next j
Print s
Next i
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Option Explicit
Private Sub Command1_Click()
Dim h As Integer
Dim i As Integer
Dim j As Integer
Dim s As String
Dim Dt As Integer
Dim t As Integer
Dim k As Integer
Dim p As Integer
Dim YesNo As Boolean
p = 0
h = Val(InputBox("输入一个[1,9]之间的正整数!"))
For i = 1 To 2 * h - 1
t = Abs(h - i)
If t > 0 Then
s = Space(t)
Else
s = ""
End If
If Not YesNo Then
p = p + 1
Else
p = p - 1
End If
If p > h Then
YesNo = True
p = p - 2
End If
Dt = h
k = 0
For j = 1 To 2 * p - 1
s = s & CStr(Dt)
k = k + 1
If k < p Then
Dt = Dt - 1
Else
Dt = Dt + 1
End If
Next j
Print s
Next i
End Sub
Private Sub Command1_Click()
Dim h As Integer
Dim i As Integer
Dim j As Integer
Dim s As String
Dim Dt As Integer
Dim t As Integer
Dim k As Integer
Dim p As Integer
Dim YesNo As Boolean
p = 0
h = Val(InputBox("输入一个[1,9]之间的正整数!"))
For i = 1 To 2 * h - 1
t = Abs(h - i)
If t > 0 Then
s = Space(t)
Else
s = ""
End If
If Not YesNo Then
p = p + 1
Else
p = p - 1
End If
If p > h Then
YesNo = True
p = p - 2
End If
Dt = h
k = 0
For j = 1 To 2 * p - 1
s = s & CStr(Dt)
k = k + 1
If k < p Then
Dt = Dt - 1
Else
Dt = Dt + 1
End If
Next j
Print s
Next i
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询