TA的每日心情 | 擦汗 2014-8-19 06:31 |
---|
签到天数: 296 天 连续签到: 1 天 [LV.8]以坛为家I
|
int cube_record[6][9]={{4,4,2,2,3,4,1,7,5},{2,4,1,7,5,3,7,1,2},{7,5,7,5,2,3,4,3,2},
{3,5,1,1,7,2,4,7,7},{5,3,3,5,1,4,3,1,3},{5,1,1,2,4,7,4,2,5}};
typedef enum colors
{blue=1,red,yellow,green,white,orange}Colors;//6种颜色
// 1 2 3 4 5 7
typedef struct surface
{
Colors s[4][4];
}Surface;//每个面有3*3个小格,从下标1开始表示,每一面的颜色是固定的
typedef struct cube
{
Surface up,down,front,back,left,right;
}Cube;//魔方的6个面
////////////////中间的省略了///////////////////////
void UpEdgeRestore(Cube *magiccube)//顶棱还原
{
int i;
char *s[4]={"f","l","b","r"};
int n;
char ch[3];
while(magiccube->front.s[1][1]!=magiccube->front.s[2][2])
MoveCube(magiccube,"u",1);
while(!(magiccube->front.s[1][2]==magiccube->front.s[2][2]&&magiccube->left.s[1][2]==magiccube->left.s[2][2]
&&magiccube->back.s[1][2]==magiccube->back.s[2][2]&&magiccube->right.s[1][2]==magiccube->right.s[2][2]))
{
Surface *sur[4]={&magiccube->front,&magiccube->left,&magiccube->back,&magiccube->right};
//在这出错了
Cube.c(831): error: #28: expression must have a constant value
Surface *sur[4]={&magiccube->front,&magiccube->left,&magiccube->back,&magiccube->right};
///
for(i=0;i<4;i++)
{
n=0;
if(sur->s[1][1]==sur->s[1][2]&&sur->s[1][2]==sur->s[1][3])
{
while(sur[(i+n)%4]->s[1][1]!=sur[(i+n)%4]->s[2][2])
{
MoveCube(magiccube,"u",1);
n++;
}
break;
}
}
strcpy(ch,s[(i+n+1)%4]);
MoveCube(magiccube,ch,1);
MoveCube(magiccube,"u",3);
MoveCube(magiccube,ch,1);
MoveCube(magiccube,"u",1);
MoveCube(magiccube,ch,1);
MoveCube(magiccube,"u",1);
MoveCube(magiccube,ch,1);
MoveCube(magiccube,"u",3);
MoveCube(magiccube,ch,3);
MoveCube(magiccube,"u",3);
MoveCube(magiccube,ch,2);
while(magiccube->front.s[1][1]!=magiccube->front.s[2][2])
MoveCube(magiccube,"u",1);
}
}
错在哪儿 我用的MDK ---------------求指导
|
|