#include <stdio.h>#include <stdlib.h>#include <windows.h>int main(){ char a[50][50]={"###############################", "#2 # #e # e# # #", "# ## # # # # ## ## # ##", "## # ## # # ##", "# # # ## #### ## # ### ", "## ### ## ## ## ### # # # #", "##e### # # ## # # # # #", "# # # ## # # # # #", "# e ### # #e# ## # ##", "# ## ## # # ### # ##", "# # # ####### #", "# # # ###e # # ### # #", "# # # # # #### ##### ###", "#e # # # ###", "###############################", }; int i,x,y,p,q,b; char ch; x=1; y=1; p=4; q=31;b=60; for(i=0;i<=15;i++) puts(a[i]); while(x!=p || y!=q) { ch=getch(); if(ch=='k')//k向下 { if(a[x+1][y]!='#') { a[x][y]=' '; x++; a[x][y]='2'; } } if(ch=='i')//i向上 { if(a[x-1][y]!='#') { a[x][y]=' '; x--; a[x][y]='2'; } } if(ch=='j')//j向左 { if(a[x][y-1]!='#') { a[x][y]=' '; y--; } } if(ch=='l')//l向右 { if(a[x][y+1]!='#') { a[x][y]=' '; y++; a[x][y]='2'; } } system("cls"); for(i=0;i<=15;i++) puts(a[i]); } system("cls"); printf("You win!\n"); Sleep(5000); return 0;}为何不行?
- 2 回答
- 0 关注
- 1631 浏览
添加回答
举报
0/150
提交
取消