? 看着书写的!
#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
sbit key1=P1^0;
sbit key2=P1^1;
uchar code table[]={
0×3f,0×06,0×5b,0×4f,
0×66,0×6d,0×7d,0×07,
0×7f,0×6f};
uchar num;
void yans(uint);
void xians(uchar);
void keyscan();?void main()
?{
??while(1)
??{
???keyscan();
???xians(num);??}
?}?void keyscan()
?{
?? if(key1==0)
?? {
?? ?yans(10);
???if(key1==0)
???{
????num++;
????if(num==60)
?????num=0;
????while(!key1);?
???}
?? }
?? if(key2==0)
?? {
?? ?yans(10);
???if(key2==0)
???{
????if(num==0)
?????num=60;
?????num–;
????while(!key2);
???}
?? }??
?}?void xians(uchar shenm)
?{
?? uchar shi,ge;
?? shi=shenm/10;
?? ge=shenm%10;
????????
?? P1=0xfe;
?? P2=table[shi];
?? yans(5);
?? P1=0xff;
?? P2=table[ge];
?? yans(5);?}
?void yans(uint xms)
?{
??uint i,j;
??for(i=xms;i>0;i–)
???for(j=110;j>0;j–);
?}