这段是俄罗斯方块旋转的一段代码
var 
   i,j,m,n:integer;
   shiftsheet:array[1..4,1..4] of byte;
   ShiftX,ShiftY:integer;  while m=0 do
  begin
  for i:=1 to 4 do
    if shiftsheet[1,i]>0 then m:=1; 
  if m=0 then
    begin
      for j:=1 to 4-1 do
        for i:=1 to 4 do
          shiftsheet[j,i]:=shiftsheet[j+1,i];  这里我就不懂,他到底要实现什么?
      for i:=1 to 4 do
      shiftsheet[4,i]:=0;  这里?
    end;
  end;m:=0;
while m=0 do
  begin
  for j:=1 to 4 do
    if shiftsheet[j,1]>0 then m:=1;
    if m=0 then
    begin
      for i:=1 to 4 do
        for j:=1 to 4 do
          shiftsheet[j,i]:=shiftsheet[j,i+1];
    for j:=1 to 4 do
    shiftsheet[j,4]:=0;    end;
  end;n:=0;
for j:=1 to 4 do
  for i:=1 to 4 do
    begin
    if shiftsheet[j,i]>0 then
      begin
      n:=n+1;
      break;
      end;
    end;
shiftY:=n;n:=0;
for i:=1 to 4 do
  for j:=1 to 4 do
    begin
    if shiftsheet[j,i]>0 then
      begin
      n:=n+1;
      break;
      end;
    end;
shiftX:=n;   这里是不是把大于0的数读出来方在ShiftX里面?

解决方案 »

  1.   

    怎么没人回答呢
    shiftsheet是一个4*4的距阵
      

  2.   

    沒有具體代碼, 只是猜的for i:=1 to 4 do
        if shiftsheet[1,i]>0 then m:=1;  //檢查最下面一行是不是已經滿格, 可以清除了  if m=0 then   //如果m=0, 可以清除, 則
        begin
          for j:=1 to 4-1 do
            for i:=1 to 4 do
              shiftsheet[j,i]:=shiftsheet[j+1,i]; //將上行格子的, 移到下一行來
          for i:=1 to 4 do
          shiftsheet[4,i]:=0;  //最上一行, 清空
        end;
      

  3.   

    for i:=1 to 4 do
        if shiftsheet[1,i]>0 then m:=1;  //檢查最下面一行是不是已經滿格, 可以清除了
    这个好象不对吧?if m=0 then   //如果m=0, 可以清除, 則
        begin
          for j:=1 to 4-1 do
            for i:=1 to 4 do
              shiftsheet[j,i]:=shiftsheet[j,i+1]; 这个呢?i+1就是5了,那么填过去就是为0?
          for i:=1 to 4 do
          shiftsheet[4,i]:=0;    
      end;