发冠厂家
免费服务热线

Free service

hotline

010-00000000
发冠厂家
热门搜索:
行业资讯
当前位置:首页 > 行业资讯

简单计算器源程序

发布时间:2020-07-01 00:06:05 阅读: 来源:发冠厂家

#includereg51.h>#includemath.h>#define uint unsigned int#define uchar unsigned charuchar code tab[]={0xee,0xed,0xeb,0xe7,0xde,0xdd,0xdb,0xd7,0xbe,0xbd,0xbb,0xb7,0x7e,0x7d,0x7b,0x77,}; //0~f键位码表uchar code tab1[]={0x88,0Xbe,0Xc4,0X94,0Xb2,0X91,0X81,0Xbc,0X80,0X90,0xa0,0x83,0xc9,0x86,0xc1,0xe1,0xff}; //0~f字型码表void delay(uchar x) //毫秒级延时函数{uchar y; for(;x>0;x--)for(y=110;y>0;y--);}scanf() //按键处理函数 {uchar temp,temp1,i; P0=0xf0; //给P0口赋值为oxf0,用于列扫描if(P0!=0xf0) //判别是否有键按下{delay(2); if(P0!=0xf0) //再次判别是否有键按下{temp1=P0; //P0值赋给temp1P0=0x0f; //P0值赋为0x0f,用于行扫描temp=temp1|P0; //将行列扫描值合并,赋给temp}switch(temp){case 0xee:i=1; break;case 0xed:i=2; break;case 0xeb:i=3; break;case 0xe7:i=4; break;case 0xde:i=5; break;case 0xdd:i=6; break;case 0xdb:i=7; break;case 0xd7:i=8; break;case 0xbe:i=9; break;case 0xbd:i=0; break;case 0xbb:i=10; break;case 0xb7:i=11; break;case 0x7e:i=12; break;case 0x7d:i=13; break;case 0x7b:i=14; break;case 0x77:i=15; break; }}else return 16;return i;} void display(uint temp) //显示函数{uchar i;uchar z[6];z[0]=16;z[1]=temp/10000;z[2]=temp%10000/1000;z[3]=temp%1000/100;z[4]=temp%100/10;z[5]=temp%10;for(i=0;i6;i++){ SBUF=tab1[z[i]]; // 根据键位值找到键码值,将键码值赋给串行口发送寄存器while(!TI); //判断串口数据发送是否完毕TI=0; //串口数据发送完毕标志清0}}E(uchar n){uint t=1;for(;n>0;n--)t=t*10;return t; }void main(void) //主函数{ uint tem,tem1;uchar x,y,fh,j,k=0;uchar zhi[6];uchar zhi1[6];while(1){if(x5!k){ if(scanf()10){delay(5);if(scanf()10){if(x==0){zhi[0]=scanf();while(scanf()!=16);}if(x==1){zhi[1]=scanf();while(scanf()!=16);}if(x==2){zhi[2]=scanf();while(scanf()!=16);}if(x==3){zhi[3]=scanf();while(scanf()!=16);}if(x==4){zhi[4]=scanf();while(scanf()!=16);} x++; tem=0;for(y=0;yx;y++){ tem=tem+zhi[y]*E(x-1-y);}display(tem);}}}if(scanf()>11scanf()16){delay(2);if(scanf()>9scanf()16){fh=scanf();while(scanf()!=16);k=1;}}if(j5k){ if(scanf()10){delay(2);if(scanf()10){if(j==0){zhi1[0]=scanf();while(scanf()!=16);}if(j==1){zhi1[1]=scanf();while(scanf()!=16);}if(j==2){zhi1[2]=scanf();while(scanf()!=16);}if(j==3){zhi1[3]=scanf();while(scanf()!=16);}if(j==4){zhi1[4]=scanf();while(scanf()!=16);}j++; tem1=0;for(y=0;yj;y++){ tem1=tem1+zhi1[y]*E(j-1-y);}display(tem1);}}}if(scanf()==11){delay(2);if(scanf()==11){ while(scanf()==11);if(fh==12)tem=tem+tem1;if(fh==13)tem=tem-tem1;if(fh==14)tem=tem*tem1;if(fh==15)tem=tem/tem1;display(tem);j=0;}}}}

威海订做西装

北京职业装定做

潍坊订做劳保工服

相关阅读