#include"reg51.h"
#define uint unsigned int
#define uchar unsigned char
sbit key1=P1^0;
sbit key2=P1^1;
sbit key3=P1^2;
sbit key4=P1^3;
 uchar code num[10]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
 delay(uint t)
 {
 uint i,j;
  for(i=0;i<t;i++)
  	for(j=110;j>0;j--);
 }
 main()
 {	 int n=0;
   	P2=~num[0];
   while(1)
   {
   	if(key1==0)
		{
		   	while(key1==0);
			{
				n++;
				P2=~num[n];
				if(n==9)
					n=0;
			}
		}
   	if(key2==0)
		{
		   	while(key2==0);
			{
				 n--;
				P2=~num[n];
				if(n==0||n==-1)
					n=9; 
					
			}
		}
   	if(key3==0)
		{
		   	while(key3==0);
			{
					n=0;
					P2=~num[n];
			}
		}
 } }
