Private Sub Command1_Click()
Open "d:\0txt" For Input As #1
Dim n As Integer
Input #1, n
For i = 1 To n
For j = 1 To n - i
Print " ";
Next j
For j = 1 To 2 i - 1
Print "";
Next j
Next i
For i = n - 1 To 1 Step -1
For j = 1 To n - i
Print " ";
Next j
For j = 1 To 2 i - 1
Print "";
Next j
Next i
End SubPrivate Sub Command1_Click()
Dim i As Integer, j As Integer, k As Integer
)", , 9)
Loop While k Mod 2 = 0
Cls
For i = -k \ 2 To k \ 2
Print Tab(Abs(i) + 1);
For j = 1 To k - 2 Abs(i)
Print "";
Next j
Next i
End Sub
Private Sub Command1 _C1ick()
For i = 0 To 3
For j = 0 To 3 - i
Print " ";
Next j
For k = 0 To 2 i + 1
Print "";
Next k
Next i
For i = 0 To 2
For j = 0 To i + 1
Print " ";
Next j
For k = 0 To 4 - 2 i
Print "";
Next k
Next i
End Sub
数字菱形 不是像你这样的吧,下面这段代码就是数字菱形,你看看吧,没看懂你写的
Private Sub Form_Click()
Dim i As Integer, j As Integer
For i = 1 To 9
Print Space(Abs(5 - i));
For j = 1 To (2 (5 - Abs(5 - i)) - 1)
Print CStr(i);
Next
Next
End Sub
Dim n%, st$ 'st为控制所显示字符或数字变量
n = InputBox("请输入数字菱形行数,必须为奇数", "数字菱形")
m = (n + 1) / 2
For i = 1 To m
st = Chr(Asc(i))
Print Tab(m + 1 - i); String(2 i - 1, st),
Next
For i = m + 1 To n
st = Chr(Asc(i))
Print Tab(i - m + 1); String(2 (n - i) + 1, st),
Next
n = InputBox("请输入字符行数,必须为奇数", "字符菱形")
m = (n + 1) / 2
For i = 1 To m
If i Mod 2 = 0 Then st = "B" Else: st = "A"
Print Tab(m + 1 - i); String(2 i - 1, st),
Next
For i = m + 1 To n
If i Mod 2 = 0 Then st = "B" Else: st = "A"
Print Tab(i - m + 1); String(2 (n - i) + 1, st),
评论列表(0条)