通过vb控制台 输出九九乘法表

 

[vb]
Module Module1 
 
    Sub Main() 
        Dim i, j, temp As Short 
        For i = 1 To 15 
            Console.Write("  ") 
        Next 
        Console.WriteLine("九九乘法表") 
        Console.WriteLine() 
        Console.Write("* ") 
        For i = 1 To 9 
            Console.Write("  {0}", i) 
        Next 
        Console.WriteLine() 
        For i = 1 To 9 
            Console.Write("{0} ", i) 
            For j = 1 To i 
                temp = i * j 
                If (temp >= 10) Then 
                    Console.Write(" {0}", temp) 
                Else 
                    Console.Write("  {0}", temp) 
                End If 
            Next j 
            Console.WriteLine(" ") 
        Next i 
        Console.ReadLine() 
    End Sub 
 
End Module 

Module Module1

    Sub Main()
        Dim i, j, temp As Short
        For i = 1 To 15
            Console.Write("  ")
        Next
        Console.WriteLine("九九乘法表")
        Console.WriteLine()
        Console.Write("* ")
        For i = 1 To 9
            Console.Write("  {0}", i)
        Next
        Console.WriteLine()
        For i = 1 To 9
            Console.Write("{0} ", i)
            For j = 1 To i
                temp = i * j
                If (temp >= 10) Then
                    Console.Write(" {0}", temp)
                Else
                    Console.Write("  {0}", temp)
                End If
            Next j
            Console.WriteLine(" ")
        Next i
        Console.ReadLine()
    End Sub

End Module
 

 运行效果:

 \