【#文档大全网# 导语】以下是®文档大全网的小编为您整理的《VB 程序 数字金字塔》,欢迎阅读!
Private Sub Form_Load() Dim n%, i%, j%, m%, x%
n = Val(InputBox("请输入一个0~9之间的整数")) If n <= 0 Or n > 9 Then
MsgBox "输入错误!请输入0~9之间的整数", vbInformation, "提示信息" End Else m = n \ 2 x = n Mod 2 For i = 1 To n If i <= m Then
Print Space(m - i + x); For j = 1 To 2 * i - 1 Print Chr(48 + i); Next j Else
Print Space(i - m - 1); For j = 1 To 2 * (n - i) + 1 Print Chr(48 + i); Next j End If
Print vbCrLf Next i End If End Sub
本文来源:https://www.wddqxz.cn/fc49ae671eb91a37f1115c13.html