今天我们学了九九乘法表的编写,但是老师留给了一课后题我们思考。九九表的右上角的表示:
1*1=1
2*1=2 2*2=4
3*1=3 3*2=6 3*3=9
4*1=4 4*2=8 4*3=12 4*4=16
............
9*1=9 9*2=18 9*3=27 9*4=36 9*5=45 9*6=54 9*7=63 9*8=72 9*9=81
那位能想出来,在此谢过了。我要详细的解析(我是新手的)
1*1=1
2*1=2 2*2=4
3*1=3 3*2=6 3*3=9
4*1=4 4*2=8 4*3=12 4*4=16
............
9*1=9 9*2=18 9*3=27 9*4=36 9*5=45 9*6=54 9*7=63 9*8=72 9*9=81
那位能想出来,在此谢过了。我要详细的解析(我是新手的)
谁能帮我解析一下
Sub printstr(Inputstr As String)
Print String(62 - Len(Inputstr), " ") & Inputstr
End SubPrivate Sub Form_Click()
Dim i As Integer, j As Integer
Dim cache As String
For i = 1 To 9
cache = ""
For j = 1 To i
cache = cache & " " & i & "*" & j & "=" & i * j
Next j
printstr cache
Next i
End Sub
Sub printstr(Inputstr As String)
'Print String(62 - Len(Inputstr), " ") & Inputstr
Print Space(62 - Len(Inputstr)) & Inputstr '就是前面加空格
End Sub Private Sub Form_Click()
Dim i As Integer, j As Integer
Dim cache As String
For i = 1 To 9
cache = ""
For j = 1 To i
cache = cache & " " & i & "*" & j & "=" & i * j
Next j
printstr cache
Next i
这代码的格式在修改一下,没对齐
Print String(62 - Len(Inputstr), " ") & Inputstr
End Sub 这里不会
还有为什么要用cache = "" 和
cache = cache & " " & i & "*" & j & "=" & i * j
cache有什么作用?
我刚开始学
很多都不懂,希望各位耐心指导。