#includereg52.h#defineucharunsignedchar#defineuintunsignedintuintnum=0,num1=0;sbitkey1=P3^0;sbitkey2=P3^1;sbitkey3=P3^2;sbitkey4=P3^3;uchartable[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};voiddelayms(uintx){uinti,j;for(i=x;i0;i--)for(j=110;j0;j--);}voiddisplay(uintnum){uintshi,ge;shi=num/10;ge=num%10;P0=table[shi];P1=0xfd;delayms(5);P0=table[ge];P1=0xfe;delayms(5);}voidkeyscan(){if(key1==0){delayms(10);if(key1==0){num1++;if(num1==60)num1=0;while(!key1)display(num1);}}if(key2==0){delayms(10);if(key2==0){if(num1==0)num1=60;num1--;while(!key2)display(num1);}}if(key3==0){delayms(10);if(key3==0){num1=0;while(!key3)display(num1);}}if(key4==0){delayms(10);if(key4==0){TR0=~TR0;while(!key4)display(num1);}}}voidmain(){TMOD=0x01;TH0=(65536-45872)/256;TL0=(65536-45872)%256;EA=1;ET0=1;while(1){keyscan();display(num1);}}voidT()interrupt1{TH0=(65536-45872)/256;TL0=(65536-45872)%256;num++;if(num==20){num1++;num=0;if(num1==60)num1=0;}}