基于matlab GUI数独游戏代码
function start_Callback(hObject, eventdata, handles)
global A B begin kk;
begin=1;%表示游戏开始
A=[3,9,6,1,2,4,7,8,5;7,8,1,9,5,6,2,4,3;2,4,5,7,8,3,6,1,9;6,3,2,8,4,1,5,9,7;...
1,7,4,5,3,9,8,2,6;9,5,8,2,6,7,4,3,1;4,1,7,6,9,8,3,5,2;5,6,3,4,1,2,9,7,8;8,2,9,3,7,5,1,6,4];
clear2(handles);
for n=1:5
%行变换
j= randi(3,1,1);
k=randi(3,1,1);
A=rchange(A,j,k);
j= randi(3,1,1)+3;
k=randi(3,1,1)+3;
A=rchange(A,j,k);
j= randi(3,1,1)+6;
k=randi(3,1,1)+6;
A=rchange(A,j,k);
%列变换
j= randi(3,1,1);
k=randi(3,1,1);
A=cchange(A,j,k);
j= randi(3,1,1)+3;
k=randi(3,1,1)+3;
A=cchange(A,j,k);
j= randi(3,1,1)+6;
k=randi(3,1,1)+6;
A=cchange(A,j,k);
end
str=get(handles.level,'Value');
switch str
case 1
k=23;
case 2
k=28;
case 3
k=33;
case 4
k=38;
case 5
k=43;
case 6
k=48;
case 7
k=53;
case 8
k=58;
case 9
k=63;
case 10
k=str2num(get(handles.ziding,'string'));
end
kk=k;
set(handles.kong,'string',['空格: ',num2str(k),'/',num2str(k)]) ;
B=wakong(k,handles);
output(handles,A,B);
set(handles.disp2,'string','已开始!');
tic;
set(handles.time,'string','计时中……');
set(handles.ans,'Enable','on');
set(handles.check,'Enable','on');
set(handles.ans,'Enable','on');
1