尝试在控制台应用程序中创建一个8x8棋盘

时间:2017-05-04 16:27:54

标签: vb.net console-application

Dim chessboard(7, 7) As Integer 

For i = 0 To chessboard.GetUpperBound(0)
    For j = 0 To chessboard.GetUpperBound(0)
        If (i + j) mod 2 = Then
            Console.out.Write(chessboard(i, j) = "B")
        Else
            Console.out.WriteLine(chessboard(i,j)="W")
        End If      
    Next
Next

Console.in.ReadLine()

1 个答案:

答案 0 :(得分:0)

因为你是新手......

    Dim chessboard(7, 7) As String

    For i As Integer = 0 To chessboard.GetUpperBound(0)
        For j As Integer = 0 To chessboard.GetUpperBound(1)
            If ((i + j) And 1) = 0 Then
                chessboard(i, j) = "B"
                Console.Write(chessboard(i, j))
            Else
                chessboard(i, j) = "W"
                Console.Write(chessboard(i, j))
            End If
        Next
        Console.WriteLine("")
    Next