解压包里是代码:(建的工程)
但总是说postype类型,无法使用。
下面是写在一起的东西:大家帮忙看看!真的谢谢,我做的是个迷宫。据我看来这是一些结构定义以及类型使用方面的问题。大家下载后在自己的机子上跑跑,看能不能帮我把问题解决,这是我们数据结构课程设计的东西,明天要交文档,今天一定要把程序跳出来,当由于学C不久,所以有些问题一时也解决不了啊,多多指教了。
#include<stdio.h>
#include<conio.h>
#include<alloc.h>
#include<stdlib.h>
#define OK 1
#define ERROR 0
#define TRUE 1
#define FALSE 0
#define OVERFLOW 0
#define STACK_INIT_SIZE 100
#define STACKINCREMENT 10
typedef struct
{
int x;
int y;
int value; //value的值被赋予1,0以表示墙还是路
}postype;
typedef struct
{
int ord;
postype seat;
int direct; //分别以1,2,3,4代表下一步的走向
}mazemap;
//堆栈中用到的数据类型,相当于是(即:mazemap的类型)
typedef struct
{
mazemap *base;
mazemap *top;
int stacksize;
}mapstack;
//整个地图要用到的堆栈
void initstack (mapstack S)
{
S.base=(mazemap*)malloc(STACK_INIT_SIZE*sizeof(mazemap));
    if(!S.base)
    {
        exit(OVERFLOW);
        S.top=S.base;
        S.stacksize=STACK_INIT_SIZE;
    }
}
int pop (mapstack S,mazemap e)
{
    if(S.top==S.base)
    {
       return ERROR;
    }
    e=*--S.top;
    return OK;
}
int push (mapstack S,mazemap e)
{
    if(S.top-S.base>=S.stacksize)
    {
       S.base=(mazemap*)realloc(S.base,(S.stacksize+STACKINCREMENT)*sizeof(mazemap));
       if(!S.base)
       {
        exit(OVERFLOW);
       }
       S.top=S.base+S.stacksize;
       S.stacksize+=STACKINCREMENT;
    }
    *S.top++=e;
    return OK;
}
int StackEmpty (mapstack S)
{
    if(S.base==S.top)
    {
       return 1;
    }
    else
    {
       return 0;
    }
}
void ini_path (postype *path_point)
{
int i,j,k=0;
 int total_image[10][10]=
 {
  1,1,1,1,1,1,1,1,1,1,
  1,0,0,1,0,0,0,1,0,1,
  1,0,0,1,0,0,0,1,0,1,
  1,0,0,0,0,1,1,0,1,1,
  1,0,1,1,1,0,0,1,0,1,
  1,0,0,0,1,0,0,0,0,1,
  1,0,1,0,0,0,1,0,1,1,
  1,0,1,1,1,1,0,0,1,1,
  1,1,1,0,0,0,1,0,1,1,
  1,1,1,1,1,1,1,1,1,1
 };
 for(i=0;i<10;i++)
 {
  for(j=0;j<10;j++)
  {
   (path_point+k)->x=i;
   (path_point+k)->y=j;
   (path_point+k)->value=total_image[i][j];
   k++;
  }
 }
}
//The foudation of the map by 1/0
void pass (postype map_node)
{
 int n=0;
 static int m=0;
 if(!map_node.value)
 {
  for(n=0;n<m;n++)
  {
   if(map_node==path_save[n])
   {
    break;
   }
  }
 }
 if(n==m)
 {
  path_save[m]=map_node;
  m++;
 }
}
nextpos (postype *cursor, int i)
{
 switch(i)
 {
  case '1': cursor->x=cursor->x+1;
        cursor->value=block_path[cursor->x+10*cursor->y+1].value;
        break;
  case '2': cursor->y=cursor->y-1;
        cursor->value=block_path[cursor->x+10*cursor->y+10].value;
        break;
  case '3': cursor->cursor->x-1;
        cursor->value=block_path[cursor->x+10*cursor->y-1].value;
        break;
  case '4': cursor->y=cursor->y+1;
        cursor->value=block_path[cursor->x+10*cursor->y-10].value;
        break;
}
}
int main (void)
{
 int curstep=1;
 mazemap temp;
 mapstack MAP;
 postype curpos,START,END;
 postype block_path[100];
 postype path_save[100];
 inistack(MAP);
 ini_path(block_path);
 START=block_path[11];    //入口
 END=block_path[88];      //出口
 curpos=START;
 curstep=1;
 do
 {
   if(pass(curpos))
   {
     temp.ord=curstep;
     temp.seat=curpos;
     temp.direct=1;
push(MAP,temp);
     if(curpos.x==END.x&&curpos.y==END.y&&curpos.value==END.value)
     {
       return (TRUE);
     }
     nextpos(curpos,1);
     curstep++;
   }
   else
   {
     if(!stackempty(MAP))
     {
       pop(MAP,temp);
       while(temp.direct==4&&!stackempty(MAP))
       {
     pop(MAP,temp);
       }
       if(temp.direct<4)
       {
     temp.direct++;
     push(MAP,temp);
     nextpos(temp.seat,temp.direct);
       }
     }
   }
 }while (!stackempty(MAP));
 return 0;
}
[attach]29152[/attach](工程文件下载)



											
	    

	