POJ 1077 eight 拼图游戏 BFS(二)

2014-11-24 09:02:54 · 作者: · 浏览: 1
char map[4] = {'u','d','l','r'};

scanf("%c %c %c %c %c %c %c %c %c",input,input+1,input+2,input+3,input+4,input+5,input+6,input+7,input+8);
i = strchr(input,'x') - input;
input[i] = '9';
order_start = getOrder(input);
bfs(input,i);
if(!visit[order_dest]){
printf("unsolvable\n");
return 0;
}
//回溯
order = order_dest;
while(order != order_start){
step1[j++] = step[order][0];
order = step[order][1];
}
for(j -= 1;j>=0;j--){
printf("%c",map[ step1[j] ]);
}
printf("\n");
return 1;
}