#include<reg52.h>  
#define uchar unsigned char 
#define uint  unsigned int  
uchar temp1,temp2,temp3,aa,miaoshi,miaoge,fenshi,fenge,shishi,shige;  
uchar code table[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90}; 
void display(uchar shishi,uchar shige,uchar fenshi,uchar fenge,uchar miaoshi,uchar miaoge);  
sbit S1=P1^0; 
sbit S2=P1^1; 
sbit S3=P1^2;   
void delay(uint z); 
void init(); 
void main() 
	{    
	init();
	while(1)   
	{        
		if(S1==0)  
		{    
		temp3++; 
		 while(S1==0);  
		 }    
	 	if(S2==0)  
	 	{    
		temp2++; 
	  	while(S2==0);  
	  	}
	 	if(S3==0)  
	  	{    
		 temp1++;  
	 	while(S3==0); 
      	}   
                          
	 if(aa==20)  
	 {    aa=0;   
	 temp1++;   
	 if(temp1==60)   
	 {     
	 temp1=0;    
	 temp2++;   }    
	 if(temp2==60)   
	 {     temp2=0;    
	 temp3++;   }     
	   if(temp3==24)   
	   {     temp3=0;   }    
	    miaoshi=temp1/10;  
		 miaoge=temp1%10;   
		 fenshi=temp2/10;   
		 fenge=temp2%10;   
		 shishi=temp3/10;   
		 shige=temp3%10;   }     
		  display(shishi,shige,fenshi,fenge,miaoshi,miaoge);   }  }   
		  void delay(uint z)  
		  {    uchar x,y;    
		  for(x=z;x>0;x--)    
		  for(y=110;y>0;y--);  }   
         void display(uchar shishi,uchar shige,uchar fenshi,uchar fenge,uchar miaoshi,uchar miaoge) 
		 {  
		 P3=0x40; 
		  P0=table[miaoshi];
		   delay(5);
		      P3=0x00;
		   P3=0x80; 
		    P0=table[miaoge];
			 delay(5); 
			  P3=0x00;
			 P3=~0xf7; 
			 P0=table[fenshi];
			  delay(5);
			  P3=0x00;
			   P3=~0xef; 
			    P0=table[fenge];
				 delay(5); 
				 P3=0x00;
				 P3=~0xfe;  
				 P0=table[shishi];
				  delay(5); 
				   P3=0x00;
				  P3=~0xfd;  
				  P0=table[shige]; 
				  delay(5);
				  P3=0x00; 
				  P3=~0xdf; 
				  P0=0xbf; 
				  delay(5);
				  P3=0x00; 
				  P3=~0xfb;
				   P0=0xbf; 
				   delay(5);
				  P3=0x00; 
				   delay(5); } 
				    void init() 
					{  temp1=0; 
					 temp2=0; 
					  temp3=0;  
					  TMOD=0x01;    
					  TH0=(65536-50000)/256;  
					  TL0=(65536-50000)%256; 
					   EA=1;  
					    ET0=1; 
                        TR0=1; }  
						void timer0()interrupt 1 
						{   TH0=(65536-50000)/256; 
						 TL0=(65536-50000)%256; 
						  aa++; }   