資源描述:
《vc++_6.0_api_mfc_數(shù)獨游戲源程序代碼1》由會員上傳分享,免費在線閱讀,更多相關(guān)內(nèi)容在教育資源-天天文庫。
1、本程序是基于API技術(shù),用VC++6.0MFC開發(fā)工具編寫的,實現(xiàn)了數(shù)獨小游戲。以下為全部源程序代碼。//writtenbyluweikang//shudu.cpp:Definestheentrypointfortheapplication.//finished2010-06-20#include#include"stdafx.h"#include#include#definetPaint2//重繪定時器的標識(編號)#definetPaintTime50//窗口重繪的時間
2、間隔#defineROW9//方格的行數(shù)與列數(shù)#defineCOL9//方格的行數(shù)與列數(shù)#defineLEN40//每個方格大小為40×40像素#defineStartY3//#defineStartX3//繪制方格地圖時的邊界起始位置intCurrentX=0;intCurrentY=0;//當前操作位置voidInitMap_show();//初始化地圖intvalue[ROW][COL];//記錄每個方格中的數(shù)字voidInitvalue();//初始化方格中的數(shù)字為0intjudge();//判斷當前位置是否能輸入用戶想要輸
3、入的數(shù)字voidrandom();//實現(xiàn)隨機生成整張地圖上的數(shù)字intchange[9][9];//用于記錄各個位置的數(shù)字是否可改變,0不可變,1可變voidInitchange();//初始化change數(shù)組中的值intIsSuccess();//判斷是否完成intanswer[9][9][9];//用于保存每個方格可以填入的數(shù)字voidInitanswer();//初始化answer[81][9][9]全部為0voidbauto(intn);//自動求解voidshowhelp();//求輔助數(shù)據(jù)boolhelp=0;//是否
4、顯示輔助數(shù)據(jù)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,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