大橙子网站建设,新征程启航

为企业提供网站建设、域名注册、服务器等服务

java迷宫并求解代码 java 走迷宫

求用java语言寻找走出迷宫路线的算法

首先给定一个初始坐标,然后构建一个容器保存坐标值,之后进行迭代,横坐标+1,或者纵坐标+1,这个顺寻自己定义(四个方向),经过的“路径”保存在那个容器中,如果遇到死角,以此往回迭代,在容器中将遇到死角的那个坐标删除。最后找到自己定义的那个迷宫出口坐标。

创新互联服务项目包括平昌网站建设、平昌网站制作、平昌网页制作以及平昌网络营销策划等。多年来,我们专注于互联网行业,利用自身积累的技术优势、行业经验、深度合作伙伴关系等,向广大中小型企业、政府机构等提供互联网行业的解决方案,平昌网站推广取得了明显的社会效益与经济效益。目前,我们服务的客户以成都为中心已经辐射到平昌省份的部分城市,未来相信会继续扩大服务区域并继续获得客户的支持与信任!

关于Java走迷宫的问题。我已经有相关代码了,但是我看不懂。麻烦高手帮忙注释一下,然后再修改点儿。

package 走迷宫;

import java.awt.BorderLayout;

import java.awt.Color;

import java.awt.GridLayout;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import java.util.ArrayList;

import java.util.LinkedList;

import java.util.List;

import java.util.TimerTask;

import javax.swing.JButton;

import javax.swing.JFrame;

import javax.swing.JOptionPane;

import javax.swing.JPanel;

// 迷宫

public class Maze extends JFrame implements ActionListener {

private JPanel panel;

private JPanel northPanel;

private JPanel centerPanel;

private MazeGrid grid[][];

private JButton restart;

private JButton dostart;

private int rows;// rows 和cols目前暂定只能是奇数

private int cols;

private ListString willVisit;

private ListString visited;

private LinkedListString comed;

private long startTime;

private long endTime;

public Maze() {

rows = 25;

cols = 25;

willVisit = new ArrayListString();

visited = new ArrayListString();

comed = new LinkedListString();

init();

this.setTitle("回溯法--走迷宫");

this.add(panel);

this.pack();

this.setVisible(true);

this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

}

public void init() {

panel = new JPanel();

northPanel = new JPanel();

centerPanel = new JPanel();

panel.setLayout(new BorderLayout());

restart = new JButton("重新生成迷宫");

dostart = new JButton("开始走迷宫");

grid = new MazeGrid[rows][cols];

centerPanel.setLayout(new GridLayout(rows, cols, 1, 1));

centerPanel.setBackground(new Color(0, 0, 0));

northPanel.add(restart);

northPanel.add(dostart);

dostart.addActionListener(this);

restart.addActionListener(this);

for (int i = 0; i grid.length; i++)

for (int j = 0; j grid[i].length; j++) {

if (j % 2 == 0 i % 2 == 0)

grid[i][j] = new MazeGrid(true, 20, 20);

else

grid[i][j] = new MazeGrid(false, 20, 20);

}

grid[0][0].setVisited(true);

grid[0][0].setPersonCome(true);

grid[0][0].setStart(true);

visited.add("0#0");

grid[rows - 1][cols - 1].setEnd(true);

grid = createMap(grid, 0, 0);

for (int i = 0; i grid.length; i++)

for (int j = 0; j grid[i].length; j++) {

grid[i][j].repaint();

centerPanel.add(grid[i][j]);

}

panel.add(northPanel, BorderLayout.NORTH);

panel.add(centerPanel, BorderLayout.CENTER);

}

/**

* 生成迷宫

*

* @param mazeGrid

* @param x

* @param y

* @return

*/

public MazeGrid[][] createMap(MazeGrid mazeGrid[][], int x, int y) {

int visitX = 0;

int visitY = 0;

if (x - 2 = 0) {

if (!mazeGrid[x - 2][y].isVisited()) {

willVisit.add((x - 2) + "#" + y);

}

}

if (x + 2 cols) {

if (!mazeGrid[x + 2][y].isVisited()) {

willVisit.add((x + 2) + "#" + y);

}

}

if (y - 2 = 0) {

if (!mazeGrid[x][y - 2].isVisited()) {

willVisit.add(x + "#" + (y - 2));

}

}

if (y + 2 rows) {

if (!mazeGrid[x][y + 2].isVisited()) {

willVisit.add(x + "#" + (y + 2));

}

}

if (!willVisit.isEmpty()) {

int visit = (int) (Math.random() * willVisit.size());

String id = willVisit.get(visit);

visitX = Integer.parseInt(id.split("#")[0]);

visitY = Integer.parseInt(id.split("#")[1]);

mazeGrid[(visitX + x) / 2][(visitY + y) / 2].setMark(true);

mazeGrid[visitX][visitY].setVisited(true);

if (!visited.contains(id)) {// 将这个点加到已访问中去

visited.add(id);

}

willVisit.clear();

createMap(mazeGrid, visitX, visitY);

} else {

if (!visited.isEmpty()) {

String id = visited.remove(visited.size() - 1);// 取出最后一个元素

visitX = Integer.parseInt(id.split("#")[0]);

visitY = Integer.parseInt(id.split("#")[1]);

mazeGrid[visitX][visitY].setVisited(true);

createMap(mazeGrid, visitX, visitY);

}

}

return mazeGrid;

}

/**

* 走迷宫

*

* @param mazeGrid

* @param x

* @param y

*/

public String goMaze(MazeGrid mazeGrid[][], int x, int y) {

int comeX = 0;

int comeY = 0;

// left

if (x - 1 = 0) {

if (mazeGrid[x - 1][y].isMark()) {

if (!comed.contains((x - 1) + "#" + y))

willVisit.add((x - 1) + "#" + y);

}

}

// right

if (x + 1 cols) {

if (mazeGrid[x + 1][y].isMark()) {

if (!comed.contains((x + 1) + "#" + y))

willVisit.add((x + 1) + "#" + y);

}

}

// up

if (y - 1 = 0) {

if (mazeGrid[x][y - 1].isMark()) {

if (!comed.contains(x + "#" + (y - 1)))

willVisit.add(x + "#" + (y - 1));

}

}

// down

if (y + 1 rows) {

if (mazeGrid[x][y + 1].isMark()) {

if (!comed.contains(x + "#" + (y + 1)))

willVisit.add(x + "#" + (y + 1));

}

}

if (!willVisit.isEmpty()) {

int visit = (int) (Math.random() * willVisit.size());

String id = willVisit.get(visit);

comeX = Integer.parseInt(id.split("#")[0]);

comeY = Integer.parseInt(id.split("#")[1]);

mazeGrid[x][y].setPersonCome(false);

mazeGrid[comeX][comeY].setPersonCome(true);

mazeGrid[x][y].repaint();

mazeGrid[comeX][comeY].repaint();

willVisit.clear();

comed.add(x + "#" + y);

} else {

if (!comed.isEmpty()) {

String id = comed.removeLast();

comeX = Integer.parseInt(id.split("#")[0]);

comeY = Integer.parseInt(id.split("#")[1]);

mazeGrid[x][y].setPersonCome(false);

mazeGrid[comeX][comeY].setPersonCome(true);

mazeGrid[x][y].repaint();

mazeGrid[comeX][comeY].repaint();

comed.addFirst(x + "#" + y);

}

}

return comeX + "#" + comeY;

}

int comeX = 0;

int comeY = 0;

public void actionPerformed(ActionEvent e) {

if (e.getActionCommand().equals("重新生成迷宫")) {

refreshMap(grid);

} else if (e.getActionCommand().equals("开始走迷宫")) {

startTime = System.currentTimeMillis();

dostart.setVisible(false);

restart.setText("禁止刷新");

int delay = 1000;

int period = 500;// 循环间隔

java.util.Timer timer = new java.util.Timer();

timer.scheduleAtFixedRate(new TimerTask() {

public void run() {

if (grid[rows - 1][cols - 1].isPersonCome()) {

endTime = System.currentTimeMillis();

JOptionPane.showMessageDialog(null, "已经走出迷宫,耗时"

+ (endTime - startTime) / 1000 + "秒", "消息提示",

JOptionPane.ERROR_MESSAGE);

this.cancel();

restart.setText("重新生成迷宫");

} else {

String id = goMaze(grid, comeX, comeY);

comeX = Integer.parseInt(id.split("#")[0]);

comeY = Integer.parseInt(id.split("#")[1]);

}

}

}, delay, period);

}

}

/**

* 刷新地图

*/

public void refreshMap(MazeGrid mazeGrid[][]) {

comeX = 0;

comeY = 0;

willVisit.clear();

visited.clear();

comed.clear();

this.remove(panel);

init();

this.add(panel);

this.pack();

this.setVisible(true);

}

public static void main(String args[]) {

long start = System.currentTimeMillis();

new Maze();

long end = System.currentTimeMillis();

System.out.println("使用ArrayList生成迷宫耗时:" + (end - start) + "毫秒");

}

}

JAVA走迷宫小游戏

import java.awt.*;

import javax.swing.*;

import java.awt.event.*;

import javax.swing.event.*;

class JPanelEa1 extends JFrame implements MenuListener,ActionListener

{

JPanel mainp,p1,p2,p3,p4;

JTextField jt1;

JMenuItem mnuCopy;

JMenuItem mnuPaste;

JButton bM;

boolean isDouble = false;// 是否为实数

int opFlag = -1;

static double t1 = 0, t2 = 0, t3 = 0, result = 0;

static int opflag1 = -1, opflag2 = -1, flag = 0, resflag = 1;

int preOp, currentOp = 0;// 标准位

double op1 = 0, op2 = 0;// 操作数

double n3;

StringBuffer buf = new StringBuffer(20);

StringBuffer copyBoard = new StringBuffer(20);// 剪贴板

StringBuffer memory = new StringBuffer(20);// M系列

StringBuffer str = new StringBuffer();

public JPanelEa1()

{

p1=new JPanel();

p1.setLayout(new GridLayout(2,1,10,10));

JMenuBar mnuNotepad=new JMenuBar();

JMenu mnuEdit=new JMenu("编辑(E)");

mnuEdit.setMnemonic(KeyEvent.VK_E);

JMenu mnuCheck=new JMenu("查看(V)");

mnuCheck.setMnemonic(KeyEvent.VK_V);

JMenu mnuHelp=new JMenu("帮助(H)");

mnuCopy=new JMenuItem("复制(C)");

mnuPaste=new JMenuItem("粘贴(P)");

JMenuItem mnuVisit=new JMenuItem("查看帮助(V)");

JMenuItem mnuAbout=new JMenuItem("关于计算器(A)");

JSeparator sep=new JSeparator();

jt1=new JTextField("0.");

jt1.setEnabled(false);

jt1.setHorizontalAlignment(JTextField.RIGHT);

mnuEdit.addMenuListener(this);

mnuCheck.addMenuListener(this);

mnuHelp.addMenuListener(this);

mnuCopy.addActionListener(this);

mnuPaste.addActionListener(this);

mnuVisit.addActionListener(this);

mnuAbout.addActionListener(this);

mnuNotepad.add(mnuEdit);

mnuNotepad.add(mnuCheck);

mnuNotepad.add(mnuHelp);

mnuEdit.add(mnuCopy);

mnuEdit.add(mnuPaste);

mnuEdit.add(sep);

mnuHelp.add(mnuVisit);

mnuHelp.add(sep);

mnuHelp.add(mnuAbout);

p1.add(mnuNotepad);

p1.add(jt1);

p2=new JPanel();

p2.setLayout(new FlowLayout(FlowLayout.CENTER));

bM = new JButton(" ");

bM.setEnabled(false);

p2.add(bM);

Button b25=new Button("Backspace");

b25.addActionListener(this);

Button b26=new Button("CE");

b26.addActionListener(this);

Button b27=new Button("C");

b27.addActionListener(this);

p2.add(b25);

p2.add(b26);

p2.add(b27);

p3=new JPanel();

p3.setLayout(new GridLayout(4,6));

Button button1=new Button("MC");

button1.addActionListener(this);

Button button2=new Button("7");

button2.addActionListener(this);

Button button3=new Button("8");

button3.addActionListener(this);

Button button4=new Button("9");

button4.addActionListener(this);

Button button5=new Button("/");

button5.addActionListener(this);

Button button6=new Button("sqrt");

button6.addActionListener(this);

Button button7=new Button("MR");

button7.addActionListener(this);

Button button8=new Button("4");

button8.addActionListener(this);

Button button9=new Button("5");

button9.addActionListener(this);

Button button10=new Button("6");

button10.addActionListener(this);

Button button11=new Button("*");

button11.addActionListener(this);

Button button12=new Button("%");

button12.addActionListener(this);

Button button13=new Button("MS");

button13.addActionListener(this);

Button button14=new Button("1");

button14.addActionListener(this);

Button button15=new Button("2");

button15.addActionListener(this);

Button button16=new Button("3");

button16.addActionListener(this);

Button button17=new Button("-");

button17.addActionListener(this);

Button button18=new Button("1/x");

button18.addActionListener(this);

Button button19=new Button("M+");

button19.addActionListener(this);

Button button20=new Button("0");

button20.addActionListener(this);

Button button21=new Button("+/-");

button21.addActionListener(this);

Button button22=new Button(".");

button22.addActionListener(this);

Button button23=new Button("+");

button23.addActionListener(this);

Button button24=new Button("=");

button24.addActionListener(this);

p3.add(button1);p3.add(button2);

p3.add(button3);p3.add(button4);

p3.add(button5);p3.add(button6);

p3.add(button7);p3.add(button8);

p3.add(button9);p3.add(button10);

p3.add(button11);p3.add(button12);

p3.add(button13);p3.add(button14);

p3.add(button15);p3.add(button16);

p3.add(button17);p3.add(button18);

p3.add(button19);p3.add(button20);

p3.add(button21);p3.add(button22);

p3.add(button23);p3.add(button24);

setSize(250,150);

mainp=new JPanel();

mainp.setLayout(new GridLayout(3,1));

mainp.add(p1);

mainp.add(p2);

mainp.add(p3);

setContentPane(mainp);

setTitle("计算器");

setSize(300,300);

setVisible(true);

setDefaultCloseOperation(EXIT_ON_CLOSE);

}

public void actionPerformed(ActionEvent e)

{

String s= e.getActionCommand();

if (s.equals("复制(C)")) {

String temp = jt1.getText().trim();

copyBoard.replace(0, copyBoard.length(), temp);

mnuPaste.setEnabled(true);

} else if (s.equals("粘贴(p)")) {

jt1.setText(copyBoard.toString());

} else if (s.equals("CE")) {

// 如果是CE则清除文本框

jt1.setText("0.");

} else if (s.equals("Backspace")) {

if (!jt1.getText().trim().equals("0.")) {

// 如果文本框中有内容

if (str.length() != 1 str.length() != 0) {

jt1.setText(str.delete(str.length() - 1, str.length())

.toString());

} else {

jt1.setText("0.");

str.setLength(0);

}

}

op2 = Double.parseDouble(jt1.getText().trim());

} else if (s.equals("C")) {

// 如果是C删除当前计算

jt1.setText("0.");

op1 = op2 = 0;

str.replace(0, str.length(), " ");

preOp = currentOp = 0;

} else if (s.equals("MC")) {

// 如果是MC则清除缓冲区

String temp = "";

memory.replace(0, memory.length(), temp);

bM.setText(" ");

} else if (s.equals("MR")) {

// 如果按键为MR则恢复缓冲区的数到文本框

jt1.setText(memory.toString());

} else if (s.equals("MS")) {

// 如果按键为MS则将文本框的数存入缓冲区

String s1 = jt1.getText().trim();

memory.replace(0, memory.length(), s1);

bM.setText("M");

} else if (s.equals("M+")) {

// 如果按键为MS则将文本框值与缓冲区的数相加但不显示结果

String temp1 = jt1.getText().trim();

double dtemp = Double.parseDouble(temp1);

String temp2 = memory.toString();

dtemp += Double.parseDouble(temp2);

temp1 = String.valueOf(dtemp);

memory.replace(0, memory.length(), temp1);

} else if (s.equals("1/x")) {

// 如果按键为1/x则将文本框中的数据为它的倒数

String temp = jt1.getText().trim();

double dtemp = Double.parseDouble(temp);

jt1.setText("" + 1 / dtemp);

} else if (s.equals("sqrt")) {

// 如果按键为sqrt则将文本框中的内容求平方根

String temp = jt1.getText().trim();

double dtemp = Double.parseDouble(temp);

jt1.setText("" + Math.sqrt(dtemp));

} else if (s.equals("+")) {

str.setLength(0);

if (currentOp == 0) {

preOp = currentOp = 1;

op2 = 0;

jt1.setText("" + op1);

} else {

currentOp = preOp;

preOp = 1;

switch (currentOp) {

case 1:

op1 += op2;

jt1.setText("" + op1);

break;

case 2:

op1 -= op2;

jt1.setText("" + op1);

break;

case 3:

op1 *= op2;

jt1.setText("" + op1);

break;

case 4:

op1 /= op2;

jt1.setText("" + op1);

break;

}

}

} else if (s.equals("-")) {

str.setLength(0);

if (currentOp == 0) {

preOp = currentOp = 2;// op1=op2;op2=0;

jt1.setText("" + op1);

} else {

currentOp = preOp;

preOp = 2;

switch (currentOp) {

case 1:

op1 = op1 + op2;

jt1.setText("" + op1);

break;

case 2:

op1 = op1 - op2;

jt1.setText("" + op1);

break;

case 3:

op1 = op1 * op2;

jt1.setText("" + op1);

break;

case 4:

op1 = op1 / op2;

jt1.setText("" + op1);

break;

}

}

} else if (s.equals("*"))// *

{

str.setLength(0);

if (currentOp == 0) {

preOp = currentOp = 3;// op1=op2;op2=1;

jt1.setText("" + op1);// op1=op2;

} else {

currentOp = preOp;

preOp = 3;

switch (currentOp) {

case 1:

op1 = op1 + op2;

jt1.setText("" + op1);

break;

case 2:

op1 = op1 - op2;

jt1.setText("" + op1);

break;

case 3:

op1 = op1 * op2;

jt1.setText("" + op1);

break;

case 4:

op1 = op1 / op2;

jt1.setText("" + op1);

break;

}

}

} else if (s.equals("/"))// /

{

str.setLength(0);

if (currentOp == 0) {

preOp = currentOp = 4;// op2=1;

jt1.setText("" + op1);// op1=op2;

} else {

currentOp = preOp;

preOp = 4;

switch (currentOp) {

case 1:

op1 = op1 + op2;

jt1.setText("" + op1);

break;

case 2:

op1 = op1 - op2;

jt1.setText("" + op1);

break;

case 3:

op1 = op1 * op2;

jt1.setText("" + op1);

break;

case 4:

op1 = op1 / op2;

jt1.setText("" + op1);

break;

}

}

} else if (s.equals("="))// =

{

if (currentOp == 0) {

str.setLength(0);

jt1.setText("" + op2);

} else {

str.setLength(0);

currentOp = preOp;

switch (currentOp) {

case 1:

op1 = op1 + op2;

jt1.setText("" + op1);

break;

case 2:

op1 = op1 - op2;

jt1.setText("" + op1);

break;

case 3:

op1 = op1 * op2;

jt1.setText("" + op1);

break;

case 4:

op1 = op1 / op2;

jt1.setText("" + op1);

break;

}

currentOp = 0;

op2 = 0;

}

} else if (s.equals(".")) {

isDouble = true;

if (jt1.getText().trim().indexOf('.') != -1)

;

else {

if (jt1.getText().trim().equals("0")) {

str.setLength(0);

jt1.setText((str.append("0" + s)).toString());

}

// else

// if(jt1.getText().trim().equals("")){}//如果初时显示为空则不做任何操作

else {

jt1.setText((str.append(s)).toString());

}

}

} else if (s.equals("0"))// 如果选择的是"0"这个数字键

{

if (jt1.getText().trim().equals("0.")) {

} else {

jt1.setText(str.append(s).toString());

op2 = Double.parseDouble(jt1.getText().trim());

}

} else {

jt1.setText(str.append(s).toString());

op2 = Double.parseDouble(jt1.getText().trim());

if (currentOp == 0)

op1 = op2;

}

}

public static void main(String args[])

{

JPanelEa1 g=new JPanelEa1();

}

@Override

public void menuSelected(MenuEvent e) {

// TODO Auto-generated method stub

}

@Override

public void menuDeselected(MenuEvent e) {

// TODO Auto-generated method stub

}

@Override

public void menuCanceled(MenuEvent e) {

// TODO Auto-generated method stub

}

}

请帮忙用数据结构(java版)的知识解决这道迷宫问题的程序代码。

我这是用c写的。你可以看看,希望能帮助到你。

#include"stdlib.h"

#include"stdio.h"

#define N 50

#define M 50

int X;

int maze[N+2][M+2];

struct point{

int row,col,predecessor;

}queue[512];

int head=0,tail=0;

void shoudong_maze(int m,int n){

int i,j;

printf("\n\n");

printf("请按行输入迷宫,0表示通路,1表示障碍:\n\n");

for(i=0;im;i++)

for(j=0;jn;j++)

scanf("%d",maze[i][j]);

}

void zidong_maze(int m,int n){

int i,j;

printf("\n迷宫生成中……\n\n");

system("pause");

for(i=0;im;i++)

for(j=0;jn;j++)

maze[i][j]=rand()%2;

//由于rand()产生的随机数是从0到RAND_MAX

//RAND_MAX是定义在stdlib.h中的,其值至少为32767)

//要产生从X到Y的数,只需要这样写:k=rand()%(Y-X+1)+X;

}

void print_maze(int m,int n){

int i,j;

printf("\n迷宫生成结果如下:\n\n");

printf("迷宫入口\n");

printf("↓");

for(i=0;im;i++)

{printf("\n");

for(j=0;jn;j++)

{if(maze[i][j]==0) printf("□");

if(maze[i][j]==1) printf("■");}

}

printf("→迷宫出口\n");

}

void result_maze(int m,int n)

{ int i,j;

printf("迷宫通路(用☆表示)如下所示:\n\t");

for(i=0;im;i++)

{ printf("\n");

for(j=0;jn;j++)

{if(maze[i][j]==0||maze[i][j]==2) printf("□");

if(maze[i][j]==1) printf("■");

if(maze[i][j]==3) printf("☆");

}

}

}

void enqueue(struct point p)

{ queue[tail]=p;

tail++;

}

struct point dequeue()

{ head++;

return queue[head-1];

}

int is_empty()

{ return head==tail;

}

void visit(int row,int col,int maze[52][52])

{ struct point visit_point={row,col,head-1};

maze[row][col]=2;

enqueue(visit_point);

}

int mgpath(int maze[52][52],int m,int n)

{ X=1;

struct point p={0,0,-1};

if(maze[p.row][p.col]==1)

{ printf("\n===============================================\n");

printf("此迷宫无解\n\n");X=0;return 0;}

maze[p.row][p.col]=2;

enqueue(p);

while(!is_empty())

{p=dequeue();

if((p.row==m-1)(p.col==n-1)) break;

if((p.col+1n)(maze[p.row][p.col+1]==0)) visit(p.row,p.col+1,maze);

if((p.row+1m)(maze[p.row+1][p.col]==0)) visit(p.row+1,p.col,maze);

if((p.col-1=0)(maze[p.row][p.col-1]==0)) visit(p.row,p.col-1,maze);

if((p.row-1=0)(maze[p.row-1][p.col]==0)) visit(p.row-1,p.col,maze);

}

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 走迷宫
分享路径:http://dzwzjz.com/article/ddcshhi.html
在线咨询
服务热线
服务热线:028-86922220
TOP