资源描述:
《c语言推箱子代码》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、#include#includevoidmap1();voidmap2();voidmap3();voidshow();voidmove();voidmain(intargc,char*argv[]){time_ta,b;time(&a);system("color1E");loop1:{system("cls");//刷屏printf("tttt欢迎进入推箱子游戏tttt请按abc选择游戏ttt
2、t按d键结束");intt=getch();if(t=='d'){printf("ttt");}else{if(t=='a'){map1();gotoloop1;}if(t=='b'){map2();gotoloop1;}if(t=='c'){map3();gotoloop1;}else{printf("tttt请重新输入:");gotoloop1;}}}time(&b);printf("tttt游戏总共用时%.3d秒ttt",b-a
3、);getch();//等待读取回车符以结束程序}voidmap1(){time_tp,q,o;time(&p);inti=4,j=4,m=6,n=2,t=1,k=3;system("cls");//刷屏system("color2E");intx=1,y=7;charz,a[9][9]={/*为背景设置初始资料*/{'#','#','#','#','#','#','#','#','#'},{'#','#','#',3,0,0,0,1,'#'},{'#','#',0,0,0,'#',0,'#',
4、'#'},{'#',0,0,'#',0,0,5,0,'#'},{'#',0,5,5,3,0,0,0,'#'},{'#','#',0,'#',0,0,'#','#','#'},{'#','#',3,0,0,0,'#','#','#'},{'#','#','#','#','#','#','#','#','#'},{'#','#','#','#','#','#','#','#','#'}};show(a);//调用输出函数loop://语句标号move(a,&x,&y,i,j,m,n,t,k,&z);
5、if(a[i][j]=='!'&&a[m][n]=='!'&&a[t][k]=='!'){system("cls");//刷屏show(a);printf("ttttYOUAREWIN!");time(&q);printf("ttttt用时%.3d秒",q-p);printf("tttt*******回车重新选择*******tttt");getch();}else{time(&o);if(z=='d'){return;}if(o-p>30){loo
6、p1:system("cls");//刷屏printf("tttt时间已过请重新回车选关!");intg=getch();if(g==13)//判断是否为回车符{return;}else{gotoloop1;}}system("cls");//刷屏show(a);//调用输出函数gotoloop;}}voidmap2(){time_tp,q,o;time(&p);inti=2,j=1,m=1,n=3,t=4,k=6;system("cls");//刷屏system("color2E");
7、intx=4,y=1;charz,b[9][9]={/*为背景设置初始资料*/{'#','#','#','#','#','#','#','#','#'},{'#','#','#',3,0,'#','#','#','#'},{'#',3,'#',0,0,0,0,'#','#'},{'#',0,5,0,'#','#',0,0,'#'},{'#',1,0,5,0,0,3,0,'#'},{'#',0,0,0,0,0,0,'#','#'},{'#','#','#',0,0,5,'#','#','#'},{
8、'#','#','#','#',0,0,'#','#','#'},{'#','#','#','#','#','#','#','#','#'}};show(b);//调用输出函数loop://语句标号move(b,&x,&y,i,j,m,n,t,k,&z);if(b[i][j]=='!'&&b[m][n]=='!'&&b[t][k]=='!'){system("cls");//刷屏show(b);printf("ttttYOUAREWIN!");time(&q);printf("t