#include        <reg52.h>                        //包含头文件
#define        uchar unsigned char
#define        uint  unsigned int
uchar code table[10] =
{
0xc0,0xf9,0xa4,0xb0,       
0x99,0x92,0x82,0xf8,
0x80,0x90,
};
uchar cun[4];
uchar dd;
uint  j;                               

void delay(unsigned int v)
{
  while(v--);
}
  void main()
{
  unsigned char mdc;

                               
         j=0;                                       
         P1 = 0xff;
         delay(100);
while(1)                               
{
dd--;
if(!dd)
{
j++;dd=100;
   }               
cun[0]=j/1000;
cun[1]=j/100%10;
cun[2]=j/10%10;
cun[3]=j%10;
mdc=0;
zz:
if(mdc<4)
{
switch(mdc)
{
case 0:P2=0xfe;P1=table[cun[3]];delay(100);break;
case 1:P2=0xfd;P1=table[cun[2]];delay(100);break;
case 2:P2=0xfb;P1=table[cun[1]];delay(100);break;
case 3:P2=0xf7;P1=table[cun[0]];delay(100);break;
default:break;
}
mdc++;
P1=255;
delay(10);
goto zz;
}       
}
}