VB数字倒金字塔程序 输入1-9之间的数字,形成以下倒金字塔

7777777777777 66666666666 555555555 4444444 33333 222 1
2025-05-13 02:53:37
推荐回答(2个)
回答(1):

Private Sub Command1_Click()
Dim i, j As Integer
For i = 1 To 13
For j = 1 To i
Print " ";
Next j
For j = i To 13 - i + 1
Print Chr(56 - i);
Next
Print
Next i
End Sub
VB 测试通过!

回答(2):

Private Sub Form_Click()
Dim sst As String
Dim x, i, k As Integer
x = CInt(InputBox("输入1-9数字"))
Debug.Print x
For i = x To 1
For k = 0 To i * 2 - 1
Debug.Print i
If sst = "" Then
sst = Space(i)
Else
sst = sst & CStr(i)
End If
Next
Debug.Print sst
Print sst
sst = ""
Next
End Sub