将2D数组分配给另一个2D数组

时间:2017-11-25 08:41:07

标签: vb.net

我正在这个项目中工作,我必须比较一个数组的值本身,所以我使用了两个具有相同大小和值的二维数组,我用一个进行比较,同时对另一个进行更改,问题是当我对其中一个进行更改时,另一个也会发生变化。

有什么方法可以分配任何2D数组的值而不需要它们一起更改。

我使用的是简单的vb.net分配: x = y,它只适用于那个问题。 我还没有完成代码,这就是我现在所拥有的。

xgame = game

For i As Integer = 0 To n - 1
    For j As Integer = 0 To n - 1
        If (j = 0 And i = 0) Then
            If xgame(i, j + 1) = "1" Then
                count = count + 1
            End If
            If xgame(i + 1, j) = "1" Then
                count = count + 1
            End If
            If xgame(i + 1, j + 1) = "1" Then
                count = count + 1
            End If
            If count <= 1 Then
                game(i, j) = "-"
            End If
        ElseIf (i = 0 And ((j > 0) Or (j < n - 1))) Then
            count = 0
            If xgame(i, j - 1) = "1" Then
                count = count + 1
            End If
            If xgame(i, j + 1) = "1" Then
                count = count + 1
            End If
            If xgame(i + 1, j - 1) = "1" Then
                count = count + 1
            End If
            If xgame(i + 1, j) = "1" Then
                count = count + 1
            End If
            If xgame(i + 1, j + 1) = "1" Then
                count = count + 1
            End If
            If (count < 2 Or count > 3) Then
                game(i, j) = "-"
            ElseIf (count = 3) Then
                game(i, j) = "1"
            End If
        ElseIf (i = 0 And j = n - 1) Then
        End If
    Next
Next

0 个答案:

没有答案