【正文】
include include voidsys_init(){ P0|=0x80。include void delay(unsigned char z){ unsigned char x,y。x0。y0。}voidLed_display(unsigned char wei,unsigned char duan)。=0x0f。=0x07。 }void Calculate(void)。voidresFormat(void)。 KEYIO=0xf0。0xf0)==0xf0) return k。 if((KEYIOamp。 for(row=0。row++) { KEYIO=~(1row)。0xf0。(1(col+4))) col++。 KEYIO=0xf0。=0x7f。0xf0)!=0xf0)。 } } return k。 switch(keyValue) { case 0: nKey=7。 case 1: nKey=8。 case 2: nKey=9。 case 3: nKey=ADD。 case 4: nKey=4。 case 5: nKey=5。 case 6: nKey=6。 case 7: nKey=SUB。 case 8: nKey=1。 case 9: nKey=2。 case 10: nKey=3。 case 11: nKey=MUL。 case 12: nKey=0。 case 13: nKey=CLR。 case 14: nKey=EQU。 case 15: nKey=DIV。 default : nKey=ERROR。}include include include include unsigned char nkey。unsigned char keyValue[8]。unsigned char MathWay=0。 FormatLoop=nValideLed。FormatLoop0。 signed char tmp1=FormatLoop。(tmp11)0。 secValue+=keyValue[FormatLoop1]*tmp。 FormatLoop=nValideLed。FormatLoop0。 signed char tmp1=FormatLoop。(tmp11)0。 fstValue+=keyValue[FormatLoop1]*tmp。 for(。reschar) { unsigned long tmp=1。 for(。tmp1) tmp*=10。 resValue=keyValue[reschar]*tmp。nValideLed0。 }}void Calculate(void){ nkey=key_vect(key_scan())。 for(。nLoop) { keyValue[nLoop]=keyValue[nLoop1]。 keyValue[0]=nkey。 nValideLed=0。 MathWay=1。 case SUB: NumberFormat(0)。 keyValue[0]=0。 break。 nValideLed=0。 MathWay=3。 case DIV: NumberFormat(0)。 keyValue[0]=0。 break。 keyValue[0]=0。 break。 switch(MathWay) { case 1: resValue=fstValue+secValue。 case 2: resValue=fstValuesecValue。 case 3: resValue=fstValue*secValue。 case 4: resValue=fstValue/secValue。 } resFormat()。 } } }}include include include include include include extern signed char nValideLed。signed char DisplayLoop。 for(。 DisplayLoop=nValideLed。 } else { for(。DisplayLoop) { Led_display(DisplayLoop1,keyValue[DisplayLoop1])。 } } }}