#include<stdio.h>
/*函数作用:实加法功能
*返回值:float 返回结果
*参数:operaed 被减数 opera 减数
*/
float Calculator_add(float operaed, float opera)
{
return (operaed + opera);
}
/*函数作用:实现减法功能
*返回值:float 返回结果
*参数:operaed 被减数 opera 减数
*/
float CalculatorSubstract(float operaed, float opera)
{
return (operaed - opera);
}
*返回值:float 返回结果
*参数:operaed 被减数 opera 减数
*/
float Calculator_add(float operaed, float opera)
{
return (operaed + opera);
}
/*函数作用:实现减法功能
*返回值:float 返回结果
*参数:operaed 被减数 opera 减数
*/
float CalculatorSubstract(float operaed, float opera)
{
return (operaed - opera);
}
/*函数作用:实现减法功能
*返回值:float 返回结果
*参数:operaed 被乘数 opera 乘数
*/
float CalculatorMulti(float operaed, float opera)
{
return (operaed * opera);
}
float CalculatorDivison(float operaed, float opera)
{
return (operaed / opera);
}
/*函数作用:实现计算器功能
*返回值:float 计算结果
*参数:operaed 被操作数 opera 操作数
*/
float Calculator(char operSign,float operaed,float opera)
{
switch (operSign)
{
case '+':printf("%.2f\n", Calculator_add(operaed, opera));
break;
case '-':printf("%.2f\n", CalculatorSubstract(operaed, opera));
break;
case '*':printf("%.2f\n", CalculatorMulti(operaed, opera));
break;
case '/':printf("%.2f\n", CalculatorDivison(operaed, opera));
break;
*返回值:float 返回结果
*参数:operaed 被乘数 opera 乘数
*/
float CalculatorMulti(float operaed, float opera)
{
return (operaed * opera);
}
float CalculatorDivison(float operaed, float opera)
{
return (operaed / opera);
}
/*函数作用:实现计算器功能
*返回值:float 计算结果
*参数:operaed 被操作数 opera 操作数
*/
float Calculator(char operSign,float operaed,float opera)
{
switch (operSign)
{
case '+':printf("%.2f\n", Calculator_add(operaed, opera));
break;
case '-':printf("%.2f\n", CalculatorSubstract(operaed, opera));
break;
case '*':printf("%.2f\n", CalculatorMulti(operaed, opera));
break;
case '/':printf("%.2f\n", CalculatorDivison(operaed, opera));
break;
}
}
/*初始化变量*/
void init_Calculator()
{
/*变量 operaed 被操作数 opera 操作数*/
float operaed = 0, opera = 0;
}
/*初始化变量*/
void init_Calculator()
{
/*变量 operaed 被操作数 opera 操作数*/
float operaed = 0, opera = 0;
char operSign = 'a';
/*输入运算符 + - * / */
printf("输入运算符\n");
scanf("%c", &operSign);
getchar();
/*输入运算符 + - * / */
printf("输入运算符\n");
scanf("%c", &operSign);
getchar();
/*输入被操作数 操作数 */
printf("输入被操作数,操作数\n");
scanf("%f%f", &operaed, &opera);
getchar();
printf("输入被操作数,操作数\n");
scanf("%f%f", &operaed, &opera);
getchar();
printf("%.2f", Calculator(operSign, operaed, opera));
}
int main()
{
init_Calculator();
return 0;
}