将下面的程序改成do while ...loop怎么改?
Private Sub Form_Click()
Dim i As Integer, j As Integer
For i = 1 To 5
Print Tab(30 - i * 2);
For j = 1 To i * 2 - 1
Print "* ";
Next j
Next i
For i = 4 To 1 Step -1
Print Tab(30 - i * 2);
For j = 1 To i * 2 - 1
Print "* ";
Next j
Next i
End Sub
Private Sub Form_Click() Dim i As Integer, j As Integer i = 1 j = 1 Do While (i <= 5) Print Tab(30 - i * 2); Do While (j <= i * 2 - 1) Print "* "; j = j + 1 Loop i = i + 1 j = 1 Loop i = 4 j = 1 Do While (i >= 1) Print Tab(30 - i * 2); Do While (j <= i * 2 - 1) Print "* "; j = j + 1 Loop i = i - 1 j = 1 Loop End Sub
Private Sub Form_Click()
Dim i As Integer, j As Integer
i = 1: j = 1
Do While i <= 5
Print Tab(30 - i * 2);
For j = 1 To i * 2 - 1
Print "* ";
Next j
i = i + 1
Loop
i = 4
Do While i >= 1
Print Tab(30 - i * 2);
For j = 1 To i * 2 - 1
Print "* ";
Next j
i = i - 1
Loop
End Sub
该程序用到了双层循环,而do while ...loop 不适合该多层循环处理
Private Sub Form_Click()
Dim i As Integer, j As Integer
i = 1
j = 1
Do While (i <= 5)
Print Tab(30 - i * 2);
Do While (j <= i * 2 - 1)
Print "* ";
j = j + 1
Loop
i = i + 1
j = 1
Loop
i = 4
j = 1
Do While (i >= 1)
Print Tab(30 - i * 2);
Do While (j <= i * 2 - 1)
Print "* ";
j = j + 1
Loop
i = i - 1
j = 1
Loop
End Sub
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息