i信息学奥赛

加入QQ群:1025629106,或关注微信公众号:i信息学奥赛,获取更多学习资源。

导航

黑客帝国

Posted on 2016-12-13 14:01  shnoip  阅读(523)  评论(0编辑  收藏  举报

感谢1402周俊豪同学提供
黑客帝国(静态)

黑客帝国 - 徐老师 - Pascal程序设计

黑客帝国(动态)

黑客帝国 - 徐老师 - Pascal程序设计

uses crt;
var
  i,j,a:byte;
  t:array[0..9] of integer;  //这10个变量负责控制每一个数字条的长度,以免造成乱码
begin
  while true do begin
    for i:=0 to 9 do t[i]:=0;
 
    for j:=1 to 42 do begin  //最先的数字条和最后的数字条相差17行,屏幕共有25行,为了使最后一个数字条到屏幕最后一行时重新开始,故循环25+17=42次
      if j=1 then clrscr;  //重新开始
      delay(200);
      for i:=1 to j do begin

        if t[0]<326 then begin  //1+2+3…+24+25=325,设成326,使其到达第25行后停止
          t[0]:=t[0]+1;
          gotoxy(1,i);
          if i=j then textcolor(white)
                 else textcolor(green);
          a:=random(2);
          write(a);
        end;

        if (t[1]<326) and (i>10) then begin  //晚10行再出来
          t[1]:=t[1]+1;
          gotoxy(9,i-10);
          if i=j then textcolor(white)
                 else textcolor(green);
          a:=random(2);
          write(a);
        end;

        if (t[2]<326) and (i>8) then begin
          t[2]:=t[2]+1;
          gotoxy(17,i-8);
          if i=j then textcolor(white)
                 else textcolor(green);
          a:=random(2);
          write(a);
        end;
  
        if (t[3]<326) and (i>5) then begin
          t[3]:=t[3]+1;
          gotoxy(29,i-5);
          if i=j then textcolor(white)
                 else textcolor(green);
          a:=random(2);
          write(a);
        end;

        if (t[4]<326) and (i>15) then begin
          t[4]:=t[4]+1;
          gotoxy(34,i-15);
          if i=j then textcolor(white)
                 else textcolor(green);
          a:=random(2);
          write(a);
        end;

        if (t[5]<326) and (i>9) then begin
          t[5]:=t[5]+1;
          gotoxy(45,i-9);
          if i=j then textcolor(white)
                 else textcolor(green);
          a:=random(2);
          write(a);
        end;

        if (t[6]<326) and (i>12) then begin
          t[6]:=t[6]+1;
          gotoxy(53,i-12);
          if i=j then textcolor(white)
                 else textcolor(green);
          a:=random(2);
          write(a);
        end;
 
        if (t[7]<326) and (i>2) then begin
          t[7]:=t[7]+1;
          gotoxy(62,i-2);
          if i=j then textcolor(white)
                 else textcolor(green);
          a:=random(2);
          write(a);
        end;   

        if (t[8]<326) and (i>7) then begin
          t[8]:=t[8]+1;
          gotoxy(70,i-7);
          if i=j then textcolor(white)
                 else textcolor(green);
          a:=random(2);
          write(a);
        end;

        if (t[9]<326) and (i>17) then begin
          t[9]:=t[9]+1;
          gotoxy(80,i-17);
          if i=j then textcolor(white)
                 else textcolor(green);
          a:=random(2);
          write(a);
        end;

      end;
    end;
  end;
end.