Write a program that prints the following pattern. The number of rows (maximum 9)
should be selected by the user.
Example:
Enter the number of rows:6
1
121
12321
1234321
123454321
12345654321
Enter the number of rows:4
1
121
12321
1234321
中間的數字是置中的,如果唔明個pattern,可 copy 下列 code 到 VB 試下
我已盡力打了下列 code
Console.Write("Enter the number of rows: ")
Dim numRows As Integer = Val(Console.ReadLine())
If numRows > 0 And numRows < 10 Then
Dim h, j, num, numSpaces As Integer
For h = 1 To numRows
num = h * 2 - 1
numSpaces = numRows - h
For j = 1 To numSpaces
Console.Write(" ")
Next
For j = 1 To num
Console.Write(j)
Next
Console.WriteLine()
Next
Console.ReadLine()
Else
Console.WriteLine("Error! The range is between 1 and 9.")
Console.ReadLine()
End If
但卻顯示出
1
123
12345
1234567
123456789
希望電腦 Visual Basic 高手能夠幫助我
最好打埋你所寫的code 以及我的 code 要改的地方