先使用栈,求处任意一条路径,再使用队列,求出最短路径。代码长了点,而且由于个人水平原因,质量不是很好……但以目前我的水平也就这样了……以后得道成仙以后再写更好的代码…… #include <stdio.h> #include <stdlib.h> #include <conio.h> #define FALSE 0 #define TRUE 1 #define MAXSIZE 1000 //最大的行数 void MGPathest(int,int,int,int,char **); //void Output(struct *,int); void Display(char **,int,int); void MGPath(int,int,int,int,char **); void main(){ int i,j; int x1,y1,x2,y2; int row,low; char *MG[MAXSIZE]; //存行指针 char *tmp; puts("Input the count of the row and the low:"); scanf("%d%d",&row,&low); for(i=0;i<row;i++){ MG[i]=malloc(low*sizeof(char)); tmp=MG[i]; if(i==0||i==row-1){ for(j=0;j<low;j++) tmp[j]='X'; }//if else { tmp[0]='X';tmp[low-1]='X'; for(j=1;j<low-1;j