拼图游戏C语言代码.doc

上传人:自*** 文档编号:124934964 上传时间:2020-03-14 格式:DOC 页数:3 大小:48.31KB
返回 下载 相关 举报
拼图游戏C语言代码.doc_第1页
第1页 / 共3页
拼图游戏C语言代码.doc_第2页
第2页 / 共3页
拼图游戏C语言代码.doc_第3页
第3页 / 共3页
亲,该文档总共3页,全部预览完了,如果喜欢就下载吧!
资源描述

《拼图游戏C语言代码.doc》由会员分享,可在线阅读,更多相关《拼图游戏C语言代码.doc(3页珍藏版)》请在金锄头文库上搜索。

1、#include#include#include#include#includeint s2020,map2020;void input(int n) srand(time(0); int i,j,k,a,b,t; for (i=1;i=n;i+) for (j=1;j0;i-) for (j=n;j0;j-) a=rand()%i+1; b=rand()%j+1; t=sab; sab=sij; sij=t; int ins(int n) int i,j; for(i=1;i=n;i+) for(j=1;j=n;j+) if(sij!=mapij) return 0; return 1;vo

2、id output(int n) int i,j,k; system(cls); for(i=1;i=n;i+) for(j=1;j=n;j+) printf(sij?%-3d: ,sij); printf( ); for(j=1;j=n;j+) printf(mapij?%-3d: ,mapij); printf(n); void des() printf(tt本游戏为数字拼图1.1版本,在w,a,s,d基础n t上增加方向键控制数字板移动nn t界面仍然很简陋,仅有控制台,但已很接近图形界面nn t其中数字为可移动板,空格为可移动位置nn t按任意键返回.); if(char)getch(

3、)0) getch(); system(cls);int main() int x,y,i,j,t,k,key; char ch; begin: printf(tt#拼图游戏1.1版本欢迎您的使用#nn); printf(请输入指令 1:游戏介绍 2:开始游戏 Esc:退出游戏n); ch=getch(); system(cls); if(ch=) return 0; else if(ch=1) des();goto begin; else if(ch=2) while(1) t=1; printf(请输入拼图大小(39) Esc:上一步n); ch=getch(); if(ch=) syst

4、em(cls);goto begin; k=ch-0; if(2k&k10) input(k); else system(cls); printf(n输入有误,请重新输入!nn); continue; for(i=1;i=k;i+) for(j=1;j=k;j+) if(sij=0) x=i;y=j; output(k); while(1) printf(请输入操作 w/:上 a/:左 s/:下 d/右:右 Esc:重新开始n); ch=getch(); if(ch0) ch=getch(); key=1; switch(ch) case w:case 72:case W:if(xk) sxy

5、=sx+1y;x+;key=0;else t-;break; case a:case 75:case A:if(y1) sxy=sx-1y;x-;key=0;else t-;break; case d:case 77:case D:if(y1) sxy=sxy-1;y-;key=0;else t-;break; case :system(cls); goto begin; default :key=1;t-;break; sxy=0; output(k); if(key) printf(输入有误n); if(ins(k) printf(*G O O D !*n共用%d步nn按任意键继续.nn,t-1); if(char)getch()0) getch(); system(cls); break; else printf( 已用%d步n,t+); else system(cls); printf(输入有误请重新输入n);goto begin; return 0;

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > IT计算机/网络 > 计算机应用/办公自动化

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号