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1,0,1,2,4,4,0,0,1,0,0,0,0,0,1,1,0,0},
{0,0,1,2,2,2,1,0,0,0,4,4,4,0,0,1,1,0,0,0,0,0,1,0,0}};
然后我想改变第一对整数(x和y):
tempMapMatrix[100][100] =
{{5,5,5,5,5,1,2,3},
{5,5,5,5,5,1,2,3},
{5,5,1,1,1,1,2,3},
{5,5,1,5,5,1,2,3},
{5,5,1,1,1,1,2,3},
{5,5,5,5,5,5,5,5},
{5,5,5,5,5,1,2,3},
{5,2,2,2,5,1,2,3},
{5,2,5,2,5,1,2,3},
{5,2,2,2,5,1,2,3}};
但我收到一个错误(预期表达式)。我试过了
tempMapArray = stuff;
tempMapArray[][] = stuff;
但没有一个工作。
有什么办法可以改变矩阵中的前几个整数?