VC++60APIMFC数独游戏源程序代码1文档格式.docx

上传人:b****6 文档编号:21835149 上传时间:2023-02-01 格式:DOCX 页数:28 大小:45.69KB
下载 相关 举报
VC++60APIMFC数独游戏源程序代码1文档格式.docx_第1页
第1页 / 共28页
VC++60APIMFC数独游戏源程序代码1文档格式.docx_第2页
第2页 / 共28页
VC++60APIMFC数独游戏源程序代码1文档格式.docx_第3页
第3页 / 共28页
VC++60APIMFC数独游戏源程序代码1文档格式.docx_第4页
第4页 / 共28页
VC++60APIMFC数独游戏源程序代码1文档格式.docx_第5页
第5页 / 共28页
点击查看更多>>
下载资源
资源描述

VC++60APIMFC数独游戏源程序代码1文档格式.docx

《VC++60APIMFC数独游戏源程序代码1文档格式.docx》由会员分享,可在线阅读,更多相关《VC++60APIMFC数独游戏源程序代码1文档格式.docx(28页珍藏版)》请在冰豆网上搜索。

VC++60APIMFC数独游戏源程序代码1文档格式.docx

//用于保存每个方格可以填入的数字

voidInitanswer();

//初始化answer[81][9][9]全部为0

voidbauto(intn);

//自动求解

voidshowhelp();

//求辅助数据

boolhelp=0;

//是否显示辅助数据

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},

{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},

{4,1,9,0,0,8,2,0,0},

{0,0,6,0,7,0,0,0,9},

{0,9,5,0,6,4,0,7,1},

{1,0,7,5,0,0,0,0,0},

{0,3,4,0,1,7,5,6,8},

{0,8,1,0,0,9,6,2,4},

{0,0,2,0,0,0,0,0,3},

{0,4,0,0,2,0,0,8,5}

{0,9,0,0,0,8,0,2,0},

{0,8,0,0,9,7,0,4,0},

{0,7,0,5,2,0,9,6,8},

{0,0,7,0,4,0,0,5,3},

{0,2,9,0,3,5,0,0,0},

{0,3,5,2,7,1,6,8,0},

{0,0,1,0,8,0,5,0,0},

{0,0,0,7,0,0,0,9,4},

{0,4,8,0,5,2,1,3,6}

{0,0,5,0,0,0,1,6,7},

{0,0,7,0,4,0,0,9,0},

{3,0,0,0,0,1,0,0,0},

{0,5,1,0,3,0,0,0,0},

{0,2,3,0,1,8,5,0,0},

{0,8,0,7,9,5,3,0,2},

{1,3,6,0,5,0,2,8,0},

{0,7,0,1,8,3,0,5,6},

{5,9,8,0,6,0,7,0,1}

{0,1,8,0,0,0,6,2,0},

{0,7,9,0,0,0,5,8,0},

{0,0,6,0,0,5,0,1,0},

{0,5,2,0,3,7,9,0,8},

{0,0,1,5,2,8,4,7,3},

{0,3,7,0,9,6,0,0,1},

{0,0,0,0,7,4,8,3,2},

{0,0,0,0,1,0,0,4,5},

{0,8,0,0,5,0,0,9,6}

{//特殊

{0,0,1,0,0,0,0,0,7},

{0,7,8,5,6,0,3,9,2},

{0,0,9,0,4,0,1,6,0},

{0,2,3,0,0,5,9,0,6},

{0,9,7,3,0,2,0,0,0},

{0,0,0,9,0,6,7,2,3},

{0,4,0,1,2,9,0,7,0},

{7,1,0,0,3,8,0,4,9},

{0,8,0,0,5,0,0,3,0}

{//第八种

{0,1,2,0,0,9,0,5,8},

{0,4,0,0,0,8,6,0,9},

{9,0,8,0,5,0,3,1,2},

{0,0,1,7,9,5,8,0,0},

{0,7,3,0,0,0,0,9,1},

{0,0,9,0,3,2,0,0,7},

{0,5,7,0,2,4,0,6,3},

{0,9,0,0,0,0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,0},

{0,0,5,0,7,3,0,8,1},

{6,0,0,0,3,0,0,4,0},

{0,0,7,0,9,4,0,6,2},

{0,5,9,0,0,0,0,3,7}

{0,0,0,2,0,0,0,0,9},

{5,2,0,0,0,9,4,0,3},

{0,8,9,0,0,0,0,0,0},

{0,0,0,9,7,6,0,1,4},

{0,9,4,5,2,8,3,7,0},

{0,6,0,3,0,0,9,0,5},

{0,1,3,4,5,2,6,0,0},

{0,0,2,8,0,1,0,0,7},

{0,0,8,6,3,7,2,4,0}

{//第16种

{0,7,9,0,1,4,0,0,6},

{0,1,0,0,2,7,0,0,0},

{0,0,6,0,8,9,0,1,7},

{9,5,0,0,3,2,6,7,0},

{0,6,7,4,9,0,0,0,8},

{0,3,1,0,6,0,0,0,0},

{0,0,5,0,0,1,3,6,2},

{0,0,0,8,7,3,5,4,1},

{0,0,0,0,5,0,0,8,9}

{0,0,5,0,6,0,0,0,9},

{0,0,0,0,1,8,2,4,5},

{8,9,2,3,0,0,0,7,0},

{0,5,7,0,8,9,0,0,3},

{0,2,1,0,0,6,0,9,0},

{0,6,8,0,3,2,0,0,1},

{0,8,0,0,2,1,0,6,0},

{0,1,4,0,0,0,0,3,7},

{0,0,9,8,4,0,5,1,2}

{0,5,0,0,9,2,1,3,6},

{0,0,0,0,5,4,0,0,8},

{1,0,0,0,8,3,0,5,9},

{0,8,3,9,2,0,0,1,4},

{7,0,0,5,0,0,0,8,2},

{0,2,0,0,3,0,0,6,0},

{9,3,5,2,0,8,7,0,0},

{0,6,7,4,1,5,8,0,0},

{0,0,0,0,0,0,0,2,5}

{0,3,7,2,0,9,0,0,4},

{0,8,9,0,0,0,1,0,7},

{0,5,6,7,1,8,0,0,0},

{0,6,0,3,9,0,0,0,0},

{0,0,2,0,7,5,0,4,8},

{0,7,4,0,0,2,0,0,0},

{6,4,0,8,0,1,7,0,2},

{7,0,3,9,4,6,0,8,1},

{0,1,8,0,0,0,0,3,0}

{//第20种

{0,3,5,0,0,9,0,2,7},

{0,2,9,3,5,1,0,6,8},

{0,0,0,0,0,4,0,0,9},

{0,5,0,5,6,0,0,0,3},

{8,7,0,5,0,3,0,0,2},

{0,4,0,0,0,2,0,0,5},

{6,0,4,0,3,7,2,0,0},

{0,1,3,9,2,0,8,7,4},

{0,0,0,0,0,5,0,9,6}

}

{//测试数据

{7,1,2,3,6,9,4,5,8},

{3,4,5,2,1,8,6,7,9},

{9,6,8,4,5,7,3,1,2},

{4,2,1,7,9,5,8,3,6},

{5,7,3,8,4,6,2,9,1},

{6,8,9,1,3,2,5,4,7},

{8,5,7,9,2,4,1,6,3},

{1,9,4,6,8,3,7,2,5},

{2,3,6,5,7,1,0,8,4}

};

LRESULTCALLBACKWndProc(HWND,UINT,WPARAM,LPARAM);

//窗口处理函数

intAPIENTRYWinMain(HINSTANCEhInstance,

HINSTANCEhPrevInstance,

LPSTRlpCmdLine,

intiCmdShow)

{

//writtenbyluweikang

//TODO:

Placecodehere.

staticTCHARszAppName[]=TEXT("

Russion"

);

HWNDhwnd;

MSGmsg;

WNDCLASSwndclass;

wndclass.style=CS_HREDRAW|CS_VREDRAW;

wndclass.lpfnWndProc=WndProc;

wndclass.cbClsExtra=0;

wndclass.cbWndExtra=0;

wndclass.hInstance=hInstance;

wndclass.hIcon=LoadIcon(NULL,IDI_APPLICATION);

wndclass.hCursor=LoadCursor(NULL,IDC_ARROW);

wndclass.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);

wndclass.lpszMenuName=NULL;

wndclass.lpszClassName=szAppName;

if(!

RegisterClass(&

wndclass))

MessageBox(NULL,TEXT("

ProgramrequiresWindowsNT!

"

),

szAppName,MB_ICONERROR);

return0;

hwnd=CreateWindow(szAppName,TEXT("

数独游戏"

),

WS_OVERLAPPED|WS_SYSMENU|WS_BORDER,

CW_USEDEFAULT,CW_USEDEFAULT,

(COL+4)*LEN+2,//窗口宽度

ROW*LEN+40,//窗口高度(包括标题栏部分29pix)

NULL,NULL,hInstance,NULL);

ShowWindow(hwnd,iCmdShow);

UpdateWindow(hwnd);

while(GetMessage(&

msg,NULL,0,0))

TranslateMessage(&

msg);

DispatchMessage(&

returnmsg.wParam;

}

voidInitvalue()//初始化地图上的每一个值,使其为零

inty,x;

for(y=0;

y<

ROW;

y++)

for(x=0;

x<

COL;

x++)

{

value[y][x]=0;

}

voidInitchange()

introw2,col2;

for(row2=0;

row2<

9;

row2++)

for(col2=0;

col2<

col2++)

if(value[row2][col2]==0)change[row2][col2]=1;

elsechange[row2][col2]=0;

voidInitanswer()

inta,b,c;

for(a=0;

a<

a++)

for(b=0;

b<

b++)

for(c=0;

c<

c++)

answer[a][b][c]=0;

intIsSuccess()

introw4,col4;

intcount[]={81,9,9,9,9,9,9,9,9,9};

for(row4=0;

row4<

row4++)

for(col4=0;

col4<

col4++)

count[value[row4][col4]]--;

if(count[1]==0&

&

count[2]==0&

count[3]==0&

count[4]==0&

count[5]==0&

count[6]==0&

count[7]==0&

count[8]==0&

count[9]==0)

return1;

else

intjudge(intvalue1,introw,intcol)

intdown_row,down_col,up_row,up_col;

for(down_row=0;

down_row<

row;

down_row++)//判断方格向上的格子

if(value1==value[down_row][col])return0;

for(up_row=8;

up_row>

up_row--)//判断方格向下的格子

if(value1==value[up_row][col])return0;

for(down_col=0;

down_col<

col;

down_col++)//判断方格向左的格子

if(value1==value[row][down_col])return0;

for(up_col=8;

up_col>

up_col--)//判断方格向右的格子

if(value1==value[row][up_col])return0;

inta_row=row/3,b_row=row%3,a_col=col/3,b_col=col%3;

//用于记录当前格子所在的小九宫格的位置

intmini_row,mini_col;

switch(a_row)

case0:

//这个大九宫格在最上三行

switch(a_col)

case0:

//这个大九宫格在最前三列

for(mini_row=0;

mini_row<

3;

mini_row++)

{

for(mini_col=0;

mini_col<

mini_col++)

if(value1==value[mini_row][mini_col])return0;

}

break;

case1:

//这个大九宫格在中间三列

for(mini_col=3;

6;

case2:

//这个大九宫格在最后三列

for(mini_col=6;

break;

case1:

//这个大九宫格在中间三行

for(mini_row=3;

case2:

//这个大九宫格在最下三行

for(mini_row=6;

bre

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 成人教育 > 自考

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1