⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 calculator.c

📁 在MCS51上实现计算器的功能模块 (完成加减乘除正余弦开方正余切E的幂和对数等的运算
💻 C
字号:
/*********************************************************************************************************			                           
**                                  
**                         PC control microprocessor by serial port 
**                                  
**                              Copyright 2007, shiyueyong            
**
**                                  All Rights Reserved                
**
**
**--------------文件信息--------------------------------------------------------------------------------
**文   件   名: main.c
**创   建   人: 史跃勇
**最后修改日期: 2007年9月4日
**描        述: 在MCS51上实现计算器的功能模块
**            (完成加减乘除正余弦开方正余切E的幂和对数等的运算,使用了Cx51标准库函数中math.h)
**------------------------------------------------------------------------------------------------------
** 修改人:
** 版  本:
** 日 期:
** 描 述:
**
**------------------------------------------------------------------------------------------------------
********************************************************************************************************/
/*********************************************************************************************************
** 函数名称: calculation
** 功能描述: 对键盘输入数据进行运算
** 输 入: p:进行类型的编码
           num1:第一个运算操作数
           num2:第二个运算操作数
** 输 出: 无
** 全局变量:无
** 调用模块: 无
**
** 作 者: 史跃勇
** 日 期: 2007年9月4日
**-------------------------------------------------------------------------------------------------------
** 修改人:
** 日 期:
**-------------------------------------------------------------------------------------------------------
********************************************************************************************************/
void calculator(uchar order,float m,float n)
{
 float idata result;  
 switch(order)
   {
     case(1):result=m+n;printf("The sum of %f and %f is %f\n", m,n,result);break;
     case(2):result=m-n;printf("The sub of %f and %1f is %f\n", m,n,result);break;
     case(3):result=m*n;printf("The mux of %f and %1f is %f\n", m,n,result);break;
     case(4):result=m/n;printf("The div of %f and %1f is %f\n", m,n,result);break;
     case(5):result=sin(m);printf("The sin of %f is %f\n", m,result);break;
     case(6):result=cos(m);printf("The cos of %f is %f\n", m,result);break;
     case(7):result=sqrt(m);printf("The sqrt of %f is %f\n", m,result);break;

     case(15):result=tan(m);printf("The tan of %f is %f\n", m,result);break;
     case(16):result=1/tan(m);printf("The cot of %f is %f\n", m,result);break;
     case(17):result=exp(m);printf("The exp of %f is %f\n", m,result);break;
     default:
     break;
   }
}
/**********************end****************************************/


















⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -