freepascal吧 关注:250贴子:915
  • 4回复贴,共1
rt
正在编一个扫雷,结果突然错掉了


1楼2016-12-14 20:49回复
    var
    x:array[1..20,1..20]of integer;
    i,c,u,j:integer;
    q,w:integer;
    s:array[1..20,1..20]of boolean;
    begin
    for i:=1 to 20 do
    for j:=1 to 20 do begin
    randomize;
    x[i,j]:=random(3);
    if x[i,j]>0 then x[i,j]:=1
    else inc(u);
    end;
    for i:=1 to 20 do begin
    for j:=1 to 20 do if s[i,j]=false then write('█')
    else begin
    if x[i,j]<1 then begin write('×');u:=0;end;
    if x[i,j]=1 then begin
    if x[i+1,j]=0 then c:=c+1;
    if x[i+1,j+1]=0 then c:=c+1;
    if x[i+1,j-1]=0 then c:=c+1;
    if x[i,j+1]=0 then c:=c+1;
    if x[i,j-1]=0 then c:=c+1;
    if x[i-1,j+1]=0 then c:=c+1;
    if x[i-1,j]=0 then c:=c+1;
    if x[i-1,j-1]=0 then c:=c+1;
    write(c);
    end
    end
    writeln;
    end;
    while u>0 do begin
    read(q,w);
    s[q,w]:=true;
    for i:=1 to 20 do begin
    for j:=1 to 20 do if s[i,j]=false then write('█')
    else begin
    if x[i,j]<1 then begin write('×');u:=0;end;
    if x[i,j]=1 then begin
    if x[i+1,j]=0 then c:=c+1;
    if x[i+1,j+1]=0 then c:=c+1;
    if x[i+1,j-1]=0 then c:=c+1;
    if x[i,j+1]=0 then c:=c+1;
    if x[i,j-1]=0 then c:=c+1;
    if x[i-1,j+1]=0 then c:=c+1;
    if x[i-1,j]=0 then c:=c+1;
    if x[i-1,j-1]=0 then c:=c+1;
    write(c);
    end
    end
    writeln;
    end;
    end;
    readln;
    end.


    2楼2016-12-14 20:49
    回复
      广告
      立即查看
      var
      x:array[1..20,1..20]of integer;
      i,c,u,j:integer;
      q,w:integer;
      s:array[1..20,1..20]of boolean;
      begin
      for i:=1 to 20 do
      for j:=1 to 20 do begin
      randomize;
      x[i,j]:=random(3);
      if x[i,j]>0 then x[i,j]:=1
      else inc(u);
      end;
      for i:=1 to 20 do begin
      for j:=1 to 20 do if s[i,j]=false then write('█')
      else begin
      if x[i,j]<1 then begin write('×');u:=0;end;
      if x[i,j]=1 then begin
      if x[i+1,j]=0 then c:=c+1;
      if x[i+1,j+1]=0 then c:=c+1;
      if x[i+1,j-1]=0 then c:=c+1;
      if x[i,j+1]=0 then c:=c+1;
      if x[i,j-1]=0 then c:=c+1;
      if x[i-1,j+1]=0 then c:=c+1;
      if x[i-1,j]=0 then c:=c+1;
      if x[i-1,j-1]=0 then c:=c+1;
      write(c);
      end
      end;
      writeln;
      end;
      while u>0 do begin
      read(q,w);
      s[q,w]:=true;
      for i:=1 to 20 do begin
      for j:=1 to 20 do if s[i,j]=false then write('█')
      else begin
      if x[i,j]<1 then begin write('×');u:=0;end;
      if x[i,j]=1 then begin
      if x[i+1,j]=0 then c:=c+1;
      if x[i+1,j+1]=0 then c:=c+1;
      if x[i+1,j-1]=0 then c:=c+1;
      if x[i,j+1]=0 then c:=c+1;
      if x[i,j-1]=0 then c:=c+1;
      if x[i-1,j+1]=0 then c:=c+1;
      if x[i-1,j]=0 then c:=c+1;
      if x[i-1,j-1]=0 then c:=c+1;
      write(c);
      end
      end;
      writeln;
      end;
      end;
      readln;
      end.
      有两个分号没加


      IP属地:浙江3楼2016-12-16 20:52
      收起回复
        ok,好的


        4楼2016-12-17 19:53
        回复