i信息学奥赛

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

导航

计时器

Posted on 2016-12-12 14:06  shnoip  阅读(216)  评论(0编辑  收藏  举报
感谢世外苏子恒同学提供
 
uses crt;
var
  t,i,r1,r2:word;
procedure start;
begin
  clrscr;
  textcolor(lightgreen);
  writeln;
  writeln;
  writeln('Timer Program':47);
  writeln('--by suziheng':47);
  writeln;
  writeln('Pls enter a time to start the timer':58);
  writeln('the time must be seconds(0~65535)':57);
  writeln('When time is up, you can press Enter to restart':64);
  writeln('or press controll+c to exit the program':60);
  writeln;
  writeln;
  writeln('Press Enter to start the program':56);
end;
begin
  start;
  while not eof do begin
    clrscr;
    textcolor(lightgreen);
    write('enter seconds(0~65535):');
    readln(t);
    for i:=t downto 1 do begin
      clrscr;
      if i<4 then begin textcolor(lightred); sound(1); end;
      write('time left:',i);
      delay(1000);
    end;
    randomize;
    r1:=random(8)+1;
    while not keypressed do begin
      clrscr;
      repeat
        r2:=random(8)+1;
      until r2<>r1;
      textcolor(r2);
      r1:=r2;
      writeln;
      writeln;
      writeln('time':39,chr(39),'s up!');
      writeln;
      writeln;
      writeln;
      textcolor(15);
      writeln('Press Ctrl+c to exit':50);
      writeln('Press Enter to restart':51);
      sound(1);
      delay(1000);
    end;
    nosound;
   end;
end.