?? calculator.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 + -