请教. 编译一直[Error] expected primary-expression before'*'token
#ifndef MAZE_CREATE_H
#define Maze_Create_H
#define ROWS 40
#define COLS 60
#define DIRECTION_NUM 4
#define DIRECTION_EAST 0
#define DIRECTION_SOUTH 1
#define DIRECTION_WEST 2
#define DIRECTION_NORTH 3
#include<iostream>
using namespace std;
typedef struct cell
{
bool door[DIRECTION_NUM];
}cell;
void create_Maze(int *cells, cell (*maze)[COLS]);
static void init_Maze(int *cells, cell (*maze)[COLS]);
static bool is_Connect(const int * const cells, int c1, int c2);
static bool all_Connect(const int * const cells);
static void union_Cells(int *cells, int c1, int c2);
#endif
/*
* 迷宫实现类:Maze_Create.cpp
*/
#include<stdlib.h>
#include <time.h>
int cells[ROWS*COLS];
cell maze[ROWS][COLS];
void create_Maze(int *cells, cell (*maze)[COLS])
{
int direction, c1, c2;
int CELL_NUM = ROWS*COLS;
init_Maze(cells, maze);
srand((unsigned)time(NULL));
while(1)
{
c1 = rand()%CELL_NUM;
direction = rand()%DIRECTION_NUM;
switch(direction)
{
case DIRECTION_EAST:
if(c1%COLS == COLS-1) c2 = -1;
else c2 = c1 + 1;
break;
case DIRECTION_SOUTH:
if((ROWS-1) == (c1 - c1%COLS)/COLS) c2 = -1;
else c2 = c1 + COLS;
break;
case DIRECTION_WEST:
if(c1%COLS == 0) c2 = -1;
else c2 = c1 - 1;
break;
case DIRECTION_NORTH:
if(0 == (c1 - c1%COLS)/COLS) c2 = -1;
else c2 = c1 - COLS;
break;
default:
printf("error on random numbers/n");
exit(0);
break;
}
if(c2 < 0) continue;
if(is_Connect(cells, c1, c2)) continue;
else
{
union_Cells(cells, c1, c2);
maze[(c1-c1%COLS)/COLS][c1%COLS].door[direction] = true;
maze[(c2-c2%COLS)/COLS][c2%COLS].door[(direction+2)%DIRECTION_NUM] = true;
}
if(is_Connect(cells, 0, CELL_NUM - 1)) break;
}
}
void init_Maze(int *cells, cell (*maze)[COLS])
{
int i, j, k;
for(i = 0; i < ROWS; i++)
{
for(j = 0; j < COLS; j++)
{
for(k = 0; k < DIRECTION_NUM; k++)
maze[i][j].door[k] = false;
}
}
maze[0][0].door[DIRECTION_WEST] = true;
maze[ROWS-1][COLS-1].door[DIRECTION_EAST] = true;
for(i = 0; i < ROWS*COLS; i++)
{
cells[i] = -1;
}
}
bool is_Connect(const int * const cells, int c1, int c2)
{
while(cells[c1] >= 0) c1 = cells[c1];
while(cells[c2] >= 0) c2 = cells[c2];
if(c1 == c2)
return true;
else
return false;
}
/*
* if the two adjacent rooms are not connect, remove the wall between them(or fix a door)
*/
void union_Cells(int *cells, int c1, int c2)
{
while(cells[c1] >= 0) c1 = cells[c1];
while(cells[c2] >= 0) c2 = cells[c2];
if(cells[c1] > cells[c2])
{
cells[c1] = c2;
}
else
{
if(cells[c1] == cells[c2]) cells[c1]--;
cells[c2] = c1;
}
}
bool all_Connect(const int * const cells)
{
int i, count_root = 0;
for(i = 0; i < ROWS*COLS; i++)
{
if(cells[i] < 0) count_root++;
}
if(1 == count_root)
return true;
else
return false;
}
int main()
{
int *cells;
create_Maze(cells,cell*maze[COLS]);
}
一个生成迷宫的程序,函数已经写好了,但是主程序引用一直出错,暂时看不出怎么改,各位帮帮忙。