各位高手,帮我看一下为啥鼠标用不了(扫雷)
pascal吧
全部回复
仅看楼主
level 1
uses crt,mouse;
type
newdown=record
tfl:array[0..101,0..101]of longint;
roundl:array[0..101,0..101]of longint;
uoc:array[0..101,0..101]of longint;
end;
var
tnt:newdown;
a,b,i,j,leinumber,k,t,lie,hang:longint;
procedure loading;
var
x,y,i,j:longint;
begin
randomize;
for i:=1 to leinumber do
begin
repeat
x:=random(a-1)+1;
y:=random(b-1)+1;
until tnt.tfl[x,y]=0;
tnt.tfl[x,y]:=1;
end;
for i:=1 to a do
for j:=1 to b do
if tnt.tfl[i,j]=0 then
tnt.roundl[i,j]:=tnt.tfl[i-1,j-1]+tnt.tfl[i-1,j]+tnt.tfl[i-1,j+1]+tnt.tfl[i,j-1]+tnt.tfl[i,j+1]+tnt.tfl[i+1,j-1]+tnt.tfl[i+1,j]+tnt.tfl[i+1,j+1];
end;
procedure printer;
var
i,j:longint;
begin
for i:=1 to a do
for j:=1 to b do
if tnt.uoc[i,j]=2 then begin gotoxy(j,i);write('@');end
else if tnt.uoc[i,j]=3 then begin gotoxy(j,i);write('?');end
else if tnt.uoc[i,j]=0 then begin gotoxy(j,i);write('*');end
else if tnt.uoc[i,j]=1 then begin tnt.uoc[i,j]:=-1;gotoxy(j,i);write(tnt.roundl[i,j]);end;
end;
procedure find(i,j:longint);
begin
if (i<1)or(j<1)or(i>100)or(j>100)or(tnt.uoc[i,j]=1) then exit
else tnt.uoc[i,j]:=1;
if tnt.roundl[i,j]<>0 then exit
else begin find(i-1,j-1);find(i-1,j);find(i-1,j+1);find(i,j-1);find(i,j+1);find(i+1,j-1);find(i+1,j);find(i+1,j+1);end;
end;
procedure start;
var
n,m,done:longint;
begin
repeat
printer;
hang:=GetMouseY;
lie:=GetMouseX;
repeat
until GetMouseButtons<>0;
case GetMouseButtons of
1:if tnt.tfl[hang,lie]=1 then begin gotoxy(1,a+1);writeln('you lose');readln;exit;end
else find(hang,lie);
2:if tnt.uoc[hang,lie]=0 then begin tnt.uoc[hang,lie]:=2;if tnt.tfl[hang,lie]=1 then inc(t);end
else if tnt.uoc[hang,lie]=2 then begin tnt.uoc[hang,lie]:=3;if tnt.tfl[hang,lie]=1 then t:=t-1;end
else begin tnt.uoc[hang,lie]:=0;if tnt.tfl[hang,lie]=1 then t:=t-1;end;
3:exit;
end;
if t=leinumber then begin gotoxy(1,a+1);writeln('win');readln;exit;end;
until 1<0;
end;
begin
InitMouse;
ShowMouse;
t:=0;
hang:=1;
lie:=1;
readln(a,b,k);
leinumber:=k;
Clrscr;
loading;
start;
end.
2014年05月27日 12点05分 1
1