99秒程序:
#include
#define uint unsigned int
#define uchar unsigned char
void delay(uint);
uchar count=20;
uint i,numb=0;
uchar const table[]={0x3f,0x06,0x5b,0x4f,0x66,
0x6d,0x7d,0x07,0x7f,0x6f};
uchar pian[]={0x01,0x02};
void main()
{
TMOD=0x01;
TH0=0x4c;
TL0=0x00;
IE=0x82;
TR0=1;
while(1)
{
for(i=0;i<2;i++)
{
if(i==0)
{
P1=pian;
P0=table[numb%10];
delay(5);
}
else
{
P1=pian;
P0=table[numb/10];
delay(5);
}
}
}
}
void int50ms() interrupt 1
{
EA=0;
TR0=0;
TH0=0x4f;
TL0=0x00;
TR0=1;
EA=1;
count--;
if(count==0)
{
numb=numb+1;
count=20;
if(numb==100)
numb=0;
}
}
void delay(uint z)
{
uint x,y;
for(x=150;x>0;x--)
for(y=z;y>0;y--);
}