level 1
肥姆斯
楼主
uses crt;label 1;varo,ido,check:array[1..16,1..30]of boolean;board:array[1..16,1..30]of char;now:1..4;x,y,i,j:word;n:integer;win:boolean;procedure checkwin;var i,j:word;beginfor i:=1 to x dofor j:=1 to y doif check[i,j]<>ido[i,j] then exit;clrscr;textcolor(yellow);textbackground(black);gotoxy(5,10);write('You win!');readln;win:=true;exit;end;procedure fail;beginclrscr;textcolor(yellow);textbackground(black);clrscr;gotoxy(5,10);write('You fail!');readln;win:=true;exit;end;procedure openit(m,n:word);var h,z:integer;begino[m,n]:=false;gotoxy(n*2-1,m+2); write(board[m,n]); o[m,n]:=false;for h:=-1 to 1 dofor z:=-1 to 1 dobeginif (not(m+h in [1..x]))or(not(n+z in [1..y])) then continue;if (h=0)and(z=0) then continue;if ido[m+h,n+z] then continue;if not o[m+h,n+z] then continue;if board[m+h,n+z]=' ' then openit(m+h,n+z);gotoxy((n+z)*2-1,m+h+2); write(board[m+h,n+z]); o[m+h,n+z]:=false;end;end;procedure try(m,n:word);var h,z,k:integer;f:boolean;begink:=0; f:=true;if (board[m,n]in['1'..'9'])and(not o[m,n]) then beginfor h:=-1 to 1 dofor z:=-1 to 1 dobeginif(not(m+h in[1..x]))or(not(n+z in[1..y]))then continue;if ido[m+h,n+z] then inc(k);end;if ord(board[m,n])-48<=k then f:=false;end;if f then begintextcolor(yellow);for h:=-1 to 1 dofor z:=-1 to 1 dobeginif (not(m+h in[1..x]))or(not(n+z in[1..y]))or(not o[m+h,n+z]) then continue;gotoxy((n+z)*2-1,m+h+2); write('*');end;delay(250); textcolor(green);for h:=-1 to 1 dofor z:=-1 to 1 dobeginif (not(m+h in[1..x]))or(not(n+z in[1..y]))or(not o[m+h,n+z]) then continue;gotoxy((n+z)*2-1,m+h+2); write('=');end;textcolor(white);end elsefor h:=-1 to 1 dofor z:=-1 to 1 dobeginif (not(m+h in[1..x]))or(not(n+z in[1..y]))or(not o[m+h,n+z]) then continue;if board[m+h,n+z]=' ' then openit(m+h,n+z) else beginif board[m+h,n+z]='#' then fail;if board[m+h,n+z]in['1'..'9'] then begingotoxy((n+z)*2-1,m+h+2); write(board[m+h,n+z]); o[m+h,n+z]:=false; end;end;end;end;procedure p;var nn,h,z:integer;beginrandomize; fillchar(board,sizeof(board),' ');fillchar(check,sizeof(check),false);for i:=1 to n dobeginrepeath:=random(x)+1; z:=random(y)+1;until not check[h,z];board[h,z]:='#';check[h,z]:=true;end;for i:=1 to x dofor j:=1 to y dobeginif board[i,j]='#' then continue;nn:=0;for h:=-1 to 1 dofor z:=-1 to 1 dobeginif (not(i+h in [1..x]))or(not(j+z in [1..y])) then continue;if (h=0)and(z=0) then continue;if board[i+h,j+z]='#' then inc(nn);end;if nn<>0 then board[i,j]:=chr(48+nn);end;end;procedure zuobi;var i,j:word;begintextcolor(blue);for i:=1 to x dofor j:=1 to y doif board[i,j]='#' then begin gotoxy(j*2-1,i+2); write('='); end;textcolor(white);end;begin1:now:=1; textcolor(white); win:=false;textbackground(black);clrscr;gotoxy(25,8); write('> EASY');gotoxy(27,9); write('NORMAL');gotoxy(27,10); write('HARD');gotoxy(27,11); write('DIY');gotoxy(19,14); write('Press Space to continue.');
2007年03月30日 15点03分
1