void calculation(double x1, double x2, char c) //计算器
{
switch(c)
{
case '+':
printf("%.4f+%.4f=%.4f\n",x1,x2,x1+x2);
break;
case '-':
printf("%.4f-%.4f=%.4f\n",x1,x2,x1-x2);
break;
case '*':
printf("%.4f*%.4f=%.4f\n",x1,x2,x1*x2);
break;
case '/':
if(x2)
{
printf("%.4f/%.4f=%.4f\n",x1,x2,x1/x2);
}
else
{
printf("Wrong!Division by zero!\n");
}
break;
default:
printf("Invalid operation!\n");
break;
}
}
int main()
{
char c;
double num1,num2;
scanf("%lf%c%lf",&num1,&c,&num2);
calculation(num1, num2, c);
return 0;
}