迷宫生成java源代码 java实现迷宫程序( 七 )


}
if(p.row==m-1p.col==n-1)
{printf("\n==================================================================\n");
printf("迷宫路径为:\n");
printf("(%d,%d)\n",p.row,p.col);
maze[p.row][p.col]=3;
while(p.predecessor!=-1)
{p=queue[p.predecessor];
printf("(%d,%d)\n",p.row,p.col);
maze[p.row][p.col]=3;
}
}
else {printf("\n=============================================================\n");
printf("此迷宫无解!\n\n");X=0;}
return 0;
}
int main()
{int i,m,n,cycle=0;
while(cycle!=(-1))
{
printf("********************************************************************************\n");
printf("☆欢迎进入迷宫求解系统☆\n");
printf("设计者:尹旭 林静波(信息2班)\n");
printf("********************************************************************************\n");
printf("手动生成迷宫请按:1\n");
printf("自动生成迷宫请按:2\n");
printf("退出请按:3\n\n");
printf("********************************************************************************\n");
printf("\n");
printf("请选择你的操作:\n");
scanf("%d",i);
switch(i)
{case 1:printf("\n请输入行数:");
scanf("%d",m);
printf("\n");
printf("请输入列数:");
scanf("%d",n);
while((m=0||m50)||(n=0||n50))
{ printf("\n抱歉,你输入的行列数超出预设范围(0-50,0-50),请重新输入:\n\n");
printf("请输入行数:");
scanf("%d",m);
printf("\n");
printf("请输入列数:");
scanf("%d",n);
}
shoudong_maze(m,n);
print_maze(m,n);
mgpath(maze,m,n);
if(X!=0)
result_maze(m,n);
printf("\n\nPress Enter Contiue!\n");
getchar();
while(getchar()!='\n');
break;
case 2:printf("\n请输入行数:");
scanf("%d",m);
printf("\n");
printf("请输入列数:");
scanf("%d",n);
while((m=0||m50)||(n=0||n50))
{printf("\n抱歉,你输入的行列数超出预设范围(0-50,0-50),请重新输入:\n\n");
printf("请输入行数:");
scanf("%d",m);
printf("\n");
printf("请输入列数:");
scanf("%d",n);
}
zidong_maze(m,n);
print_maze(m,n);
mgpath(maze,m,n);
if(X!=0)
result_maze(m,n);
printf("\n\nPress Enter Contiue!\n");getchar();while(getchar()!='\n');break;
case 3:cycle=(-1);
break;
default:printf("\n");
printf("你的输入有误!\n");
printf("\nPress Enter Contiue!\n");
getchar();
while(getchar()!='\n');break;
}
}
}
迷宫生成java源代码的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于java实现迷宫程序、迷宫生成java源代码的信息别忘了在本站进行查找喔 。

推荐阅读