- #include <stdio.h>
- #define width 10
- #define height 10
- int main(int argc, const char * argv[]) {
-
- //0:可走的格子,1:墙,2:玩家,3:终点,4:箱子
- int a[height][width]={
- {1,1,1,1,1,1,1,1,1,1},
- {1,0,2,0,0,0,0,0,0,1},
- {1,0,4,1,1,0,0,0,0,1},
- {1,0,0,0,0,0,0,0,0,1},
- {1,1,1,1,1,0,0,0,0,1},
- {1,0,0,0,0,0,0,0,0,1},
- {1,0,0,0,0,0,0,0,0,1},
- {1,0,0,0,0,0,0,0,0,1},
- {1,0,0,0,0,0,0,0,0,1},
- {1,1,1,1,1,1,1,1,3,1}
- };
-
- //存储玩家下一步的方向
- char an;
- //存储玩家当前的位置x,y
- int weiZhix=0,weiZhiy=0;
- //箱子当前位置
- int Xx=0,Xy=0;
-
复制代码 |