怎么给int **的二维数组赋值
inti=0;intj=0;intmaze1[10][10]={{1,1,1,1,1,1,1,1,1,1},{1,0,0,0,1,1,0,1,0,1},{1,1,1,0,...
int i=0;int j=0;
int maze1[10][10]={
{1,1,1,1,1,1,1,1,1,1},
{1,0,0,0,1,1,0,1,0,1},
{1,1,1,0,1,0,0,0,0,1},
{1,0,1,0,0,1,1,0,1,1},
{1,0,1,1,0,0,0,1,1,1},
{1,0,0,0,1,0,0,1,0,1},
{1,0,0,1,0,1,0,0,1,1},
{1,1,1,0,0,1,0,0,0,1},
{1,0,0,0,1,0,0,1,0,1},
{1,1,1,1,1,1,1,1,1,1}};
int *maze2;
maze2=new int [10];
for(i=0;i<10;i++) //apply for eacn indicator
{
maze[i]=new int[10];
}
for(i=0;i<10;i++){
for(j=0;j<10;j++)
{
*maze2[i][j]==&maze1[i][j];
}
}
maze=new int *[10]; //apply for an indicator
for(i=0;i<10;i++) //apply for eacn indicator
{
maze[i]=new int[10];
}
for(i=0;i<10;i++){
for(j=0;j<10;j++)
{**maze[i][j]=&maze2[i][j];}
}
这样赋值有什么问题 展开
int maze1[10][10]={
{1,1,1,1,1,1,1,1,1,1},
{1,0,0,0,1,1,0,1,0,1},
{1,1,1,0,1,0,0,0,0,1},
{1,0,1,0,0,1,1,0,1,1},
{1,0,1,1,0,0,0,1,1,1},
{1,0,0,0,1,0,0,1,0,1},
{1,0,0,1,0,1,0,0,1,1},
{1,1,1,0,0,1,0,0,0,1},
{1,0,0,0,1,0,0,1,0,1},
{1,1,1,1,1,1,1,1,1,1}};
int *maze2;
maze2=new int [10];
for(i=0;i<10;i++) //apply for eacn indicator
{
maze[i]=new int[10];
}
for(i=0;i<10;i++){
for(j=0;j<10;j++)
{
*maze2[i][j]==&maze1[i][j];
}
}
maze=new int *[10]; //apply for an indicator
for(i=0;i<10;i++) //apply for eacn indicator
{
maze[i]=new int[10];
}
for(i=0;i<10;i++){
for(j=0;j<10;j++)
{**maze[i][j]=&maze2[i][j];}
}
这样赋值有什么问题 展开
1个回答
展开全部
int maze1[10][10]={
{1,1,1,1,1,1,1,1,1,1},
{1,0,0,0,1,1,0,1,0,1},
{1,1,1,0,1,0,0,0,0,1},
{1,0,1,0,0,1,1,0,1,1},
{1,0,1,1,0,0,0,1,1,1},
{1,0,0,0,1,0,0,1,0,1},
{1,0,0,1,0,1,0,0,1,1},
{1,1,1,0,0,1,0,0,0,1},
{1,0,0,0,1,0,0,1,0,1},
{1,1,1,1,1,1,1,1,1,1}};
改为:
int maze1[10][10]={
1,1,1,1,1,1,1,1,1,1,
1,0,0,0,1,1,0,1,0,1,
1,1,1,0,1,0,0,0,0,1,
1,0,1,0,0,1,1,0,1,1,
1,0,1,1,0,0,0,1,1,1,
1,0,0,0,1,0,0,1,0,1,
1,0,0,1,0,1,0,0,1,1,
1,1,1,0,0,1,0,0,0,1,
1,0,0,0,1,0,0,1,0,1,
1,1,1,1,1,1,1,1,1,1};
不用那么多个大括号。
{1,1,1,1,1,1,1,1,1,1},
{1,0,0,0,1,1,0,1,0,1},
{1,1,1,0,1,0,0,0,0,1},
{1,0,1,0,0,1,1,0,1,1},
{1,0,1,1,0,0,0,1,1,1},
{1,0,0,0,1,0,0,1,0,1},
{1,0,0,1,0,1,0,0,1,1},
{1,1,1,0,0,1,0,0,0,1},
{1,0,0,0,1,0,0,1,0,1},
{1,1,1,1,1,1,1,1,1,1}};
改为:
int maze1[10][10]={
1,1,1,1,1,1,1,1,1,1,
1,0,0,0,1,1,0,1,0,1,
1,1,1,0,1,0,0,0,0,1,
1,0,1,0,0,1,1,0,1,1,
1,0,1,1,0,0,0,1,1,1,
1,0,0,0,1,0,0,1,0,1,
1,0,0,1,0,1,0,0,1,1,
1,1,1,0,0,1,0,0,0,1,
1,0,0,0,1,0,0,1,0,1,
1,1,1,1,1,1,1,1,1,1};
不用那么多个大括号。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询