#include"stdio.h"
void main()
{
float operand1,operand2,result;
char oper;
printf(“请输入两个数和一个四则运算符(如:3,+,2):”);
scanf("%f,%c,%f",&operand1,&oper,&operand2);
switch(oper)
{
case '+': /*加法运算*/
result=operand1+operand2;
break;
case '-': /*减法运算*/
result=operand1-operand2;
break;
case '*': /*乘法运算*/
result=operand1*operand2;
break;
case '/': /*除法运算*/
result=operand1/operand2;
break;
default:
printf("非法的运算符!\n");
}
printf("结果为:%f\n",result);
}
void main()
{
float operand1,operand2,result;
char oper;
printf(“请输入两个数和一个四则运算符(如:3,+,2):”);
scanf("%f,%c,%f",&operand1,&oper,&operand2);
switch(oper)
{
case '+': /*加法运算*/
result=operand1+operand2;
break;
case '-': /*减法运算*/
result=operand1-operand2;
break;
case '*': /*乘法运算*/
result=operand1*operand2;
break;
case '/': /*除法运算*/
result=operand1/operand2;
break;
default:
printf("非法的运算符!\n");
}
printf("结果为:%f\n",result);
}