51单片机简易计算器C语言程序,用51单片机制作的简单计算器程序

  • Post author:
  • Post category:其他


三、程序源代码

#include <reg51.h>#include <intrins.h>

#include <ctype.h>

#include <stdlib.h>

#define uchar unsigned char

#define uint unsigned int

uchar operand1[9], operand2[9];

uchar operator;

void delay(uint);

uchar keyscan();

void disp(void);

void buf(uint value);

uint compute(uint va1,uint va2,uchar optor);

uchar code table[] = {0xc0,0xf9,0xa4,0xb0,0x99,

0x92,0x82,0xf8,0x80,0x90,0xff};

uchar dbuf[8] = {10,10,10,10,10,10,10,10};

void delay(uint z)

{

uint x,y;

for(x=z;x>0;x–)

for(y=110;y>0;y–);

}

uchar keyscan()

{

uchar skey;

P1 = 0xfe;

while((P1 & 0xf0) != 0xf0)

{

delay(3);

while((P1 & 0xf0) != 0xf0)

<