资源描述:
《vc++_6.0_api_mfc_数独游戏源程序代码1》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、本程序是基于API技术,用VC++6.0MFC开发工具编写的,实现了数独小游戏。以下为全部源程序代码。//writtenbyluweikang//shudu.cpp:Definestheentrypointfortheapplication.//finished2010-06-20#include#include"stdafx.h"#include#include#definetPaint2//重绘定时器的标识(编号)#definetPaintTime50//窗口重绘的时间
2、间隔#defineROW9//方格的行数与列数#defineCOL9//方格的行数与列数#defineLEN40//每个方格大小为40×40像素#defineStartY3//#defineStartX3//绘制方格地图时的边界起始位置intCurrentX=0;intCurrentY=0;//当前操作位置voidInitMap_show();//初始化地图intvalue[ROW][COL];//记录每个方格中的数字voidInitvalue();//初始化方格中的数字为0intjudge();//判断当前位置是否能输入用户想要输
3、入的数字voidrandom();//实现随机生成整张地图上的数字intchange[9][9];//用于记录各个位置的数字是否可改变,0不可变,1可变voidInitchange();//初始化change数组中的值intIsSuccess();//判断是否完成intanswer[9][9][9];//用于保存每个方格可以填入的数字voidInitanswer();//初始化answer[81][9][9]全部为0voidbauto(intn);//自动求解voidshowhelp();//求辅助数据boolhelp=0;//是否
4、显示辅助数据boolf;//成功标志inttmp=20;//记录当前地图是哪副inteasy[21][9][9]={//用于存储初级地图{{0,0,0,0,3,0,2,0,8},{0,2,8,0,4,0,1,3,0},{0,0,9,5,8,0,0,4,7},{0,3,1,0,2,0,5,9,0},{0,0,5,3,9,1,7,0,0},{0,9,0,4,7,5,8,1,3},{0,0,0,0,6,0,4,0,2},{0,0,0,0,0,3,0,6,0},{0,7,6,2,5,4,0,8,0}},{{0,0,0,0,0,4,0,5,2
5、},{0,0,5,0,0,7,0,1,4},{0,0,1,0,0,8,3,0,6},{0,1,2,0,0,6,4,3,9},{0,0,9,0,4,1,6,8,5},{0,0,6,0,3,5,2,7,1},{0,6,7,0,1,0,0,0,0},{1,5,0,0,0,3,0,2,8},{0,2,0,0,5,9,0,6,0}},{{0,7,8,4,0,0,0,3,6},{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