2 mly8410112 mly8410112 于 2014.09.25 10:46 提问

Code Blocks 下C语言编程的问题

enum Dirction{up,down,forward,back,left,right};
void main()
{ enum Direction commands[10]=
{forward,right,forward,right,forward,right,forward,right,forward,right};
int x=0,y=0;
int i=0;
for (i=0;i<10;i++)
{
move (commands[i],&x,&y);
printf("\nPosition[%d]is(%d,%d)",i+1,x,y);
}
}
int move(enum Direction command,int*px,int*py)
{
int nRet=1;
static int x=0,y=0;
switch(command)
{
case left:
x-=1;break;
case right:
x+=1;break;
case forward:
y+=1;break;
case back:
y-=1;break;
default:
nRet=0;break;
}
*px=x;
*py=y;
return nRet;
}
enum Dirction{up,down,forward,back,left,right};
void main()
{ enum Direction commands[10]=
{forward,right,forward,right,forward,right,forward,right,forward,right};
int x=0,y=0;
int i=0;
for (i=0;i<10;i++)
{
move (commands[i],&x,&y);
printf("\nPosition[%d]is(%d,%d)",i+1,x,y);
}
}
int move(enum Direction command,int*px,int*py)
{
int nRet=1;
static int x=0,y=0;
switch(command)
{
case left:
x-=1;break;
case right:
x+=1;break;
case forward:
y+=1;break;
case back:
y-=1;break;
default:
nRet=0;break;
}
*px=x;
*py=y;
return nRet;
}

enum Dirction{up,down,forward,back,left,right};
void main()
{ enum Direction commands[10]=
{forward,right,forward,right,forward,right,forward,right,forward,right};
int x=0,y=0;
int i=0;
for (i=0;i<10;i++)
{
move (commands[i],&x,&y);
printf("\nPosition[%d]is(%d,%d)",i+1,x,y);
}
}
int move(enum Direction command,int*px,int*py)
{
int nRet=1;
static int x=0,y=0;
switch(command)
{
case left:
x-=1;break;
case right:
x+=1;break;
case forward:
y+=1;break;
case back:
y-=1;break;
default:
nRet=0;break;
}
*px=x;
*py=y;
return nRet;
}

编译时显示:error: array type has incomplete element type并且提示在第三行的代码上,求指点如何解决这个问题

1个回答

u013648963
u013648963   2014.09.28 01:05
已采纳

是Direction,不是Dirction

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!