#include <stdio.h>
int main()
{
double number1;
double number2;
double a = 0;
char op;
printf("请输入一个数:\n");
scanf("%lf",&number1);
getchar();
printf("请输入一个运算符号:\n");
scanf("%c",&op);
printf("请输入一个数:\n");
scanf("%lf",&number2);
switch (op)
{
case '+':
{
a = number1 + number2;
break;
}
case '-':
{
a = number1 - number2;
break;
}
case '*':
{
a = number1 * number2;
break;
}
case '/':
{
if(number2 == 0)
{
printf("enter error!\n");
}
else
{
a = number1 / number2;
}
break;
}
default :printf("enter op error!\n");
}
printf("The answer is %lf\n",a);
return 0;
}
int main()
{
double number1;
double number2;
double a = 0;
char op;
printf("请输入一个数:\n");
scanf("%lf",&number1);
getchar();
printf("请输入一个运算符号:\n");
scanf("%c",&op);
printf("请输入一个数:\n");
scanf("%lf",&number2);
switch (op)
{
case '+':
{
a = number1 + number2;
break;
}
case '-':
{
a = number1 - number2;
break;
}
case '*':
{
a = number1 * number2;
break;
}
case '/':
{
if(number2 == 0)
{
printf("enter error!\n");
}
else
{
a = number1 / number2;
}
break;
}
default :printf("enter op error!\n");
}
printf("The answer is %lf\n",a);
return 0;
}