帮我看看这代码有什么问题?

#include
#include
#define MAXNUM 100  //顺序队列中的最大元素个数
#define DataType  //定义元素的树据类型
//定义队列
struct SeqQueue{
         //队列中的元素最大个数MAXNUM
    int f,r;
    DataType*data;
};
typedef struct SeqQueue * PSeqQueue;
//创建空队列
PSeqQueue createEmptyQueue_Link(int m){
    PSeqQueue plq;
    plq = (PSeqQueue)malloc(sizeof(struct SeqQueue));//申请节点空间
    plq ->data = (DataType*)malloc(sizeof(DataType)*m);
    if (plq ->data)
    {
        /* code */
        plq -> f =0;
        plq -> r =0;

    }
    else{
        printf("Out of space!\n");

    }
    return NULL;
}

//入队代码
void enQueue_Seq(PSeqQueue plq,int x){
    if ((int)(plq -> r + 1) % MAXNUM == plq ->f){
        /* code */
        printf("Full queue\n");
    }else{
        plq ->data[plq ->r]=x;
        plq ->r=(plq ->r +1)% MAXNUM;
    }
    
}

//判断队列是否为空 
int isQueueEmpty(PSeqQueue plq)
{
    if(plq ->f == plq ->r)
    {
        return 1;
    }
    else
    {
        return 0;
    }
}

// 队头出队列 
DataType QueuePop(PSeqQueue *plq)
{
   if(!isQueueEmpty(plq));
   return   plq;
}

//出队代码段
void deQueue(PSeqQueue plq){
    if(plq ->f == plq ->r){
        printf("Empty Queue\n");
    }
    else
    {
        plq ->f = (plq ->r +1)% MAXNUM;
    }
}

//各物品的位置判断
int farmer(int location){       //判断农夫位置
    return (0!=(location & 0x08));
}
int wolf(int location){         //判断狼的位置
    return (0!=(location & 0x04));
}
int cabbage(int location){      //判断白菜的位置
    return (0!=(location & 0x02));
}
int goat(int location){         //判断羊的位置
    return (0!=(location & 0x01));
}

//安全状态路径
int safe(int location){
    //状态安全则返回
    if(goat(location) == cabbage(location) && farmer(location) == goat(location)){
        return 0;               //羊吃白菜
    }
    if (wolf(location) == goat(location)  && wolf(location) == farmer(location))
    {
        /* code */
        return 0;               //狼吃羊
    }
    return 1;                   //其余为安全状态
}

//农夫过河问题求解过程
void farmerProblem(){
    int i,movers,location,newlocation;
     int rout[16];                           //记录过河的已考虑的路径
    PSeqQueue moveTo;                       //记录过河时的中间状态
    moveTo = createEmptyQueue_Link();       //创建空队列
    enQueue_Seq(moveTo,0x00);               //初始化状态
    for(i = 0;i<=16;i++)
    rout[i]=-1;
    rout[0]=0;
    while (!isQueueEmpty(moveTo)&&(rout[15]== -1))      //去队头做状态为当前状态
    {
        /* code */
        location=QueuePop(moveTo);
        deQueue(moveTo);
        for(movers=1;movers<=8;movers<<=1){     //考虑各种物品转移
            if((0!=(location & 0x08))  == (0!=(location & movers))){
                //农夫与移动的物品在同一侧
                newlocation = location^(0x08|movers);
                if(safe(newlocation)&&(rout[newlocation]==-1)){
                    //新状态且未处理
                    rout[newlocation]=location; //记录新状态的前驱
                    enQueue_Seq(moveTo,newlocation);    //新状态入队
                }
            }
        }
        //打印安全路径
        if (rout[15]!=-1)
        {
            /* code */
            //到达最终状态
            printf("The reverse path is:\n");
            for (location=15;location>0;location=rout[location])
            {
                /* code */
                printf("The location is :%d \n",location);
                if (location==0)
                {
                    /* code */
                    exit(0);
                }
                
            }
            
        }
        else{
            printf("No solution.\n");
        }
    }
    

}
  • 这个问题的回答你可以参考下: https://ask.csdn.net/questions/262155
  • 这篇博客也不错, 你可以看下信域安全云网可以解决我什么问题??
  • 除此之外, 这篇博客: 数组与结构体中的 为什么要有结构体? 部分也许能够解决你的问题, 你可以仔细阅读以下内容或跳转源博客中阅读:
  • 假设我们要用C语言描述一个人,凭借当前所学的C语言内置类型是无法描述的,因为int,daouble等等类型都只可以单一的描述一个值,因此结构体就孕育而生。

    结构的基础知识

    1. 结构是一些值的集合,这些值称为成员变量。结构的每个成员可以是不同类型的变量。
    2. 结构体是自定义类型。