#include
main()
{
double a,b,c;
char ch,ch1;
printf("這是一個簡單的計算程式,只支援±整數和小數的加減乘除運算,請輸入運算表示式,如:1+2,按回車鍵。\n");
scanf("%lf%c%lf%c",&a,&ch,&b,&ch1);
switch(ch)
case "+":
c=a+b;
printf("%lf+%lf=%.10lf\n",a,b,c);
break;
case "-":
c=a-b;
printf("%lf-%lf=%.10lf\n",a,b,c);
case "*":
c=a*b;
printf("%lf*%lf=%.10lf\n",a,b,c);
case "/":
c=a/b;
printf("%lf/%lf=%.10lf\n",a,b,c);
default:
printf("輸入表示式錯誤或該計算器不具備 %ch功能\n",ch);
}
#include
main()
{
double a,b,c;
char ch,ch1;
printf("這是一個簡單的計算程式,只支援±整數和小數的加減乘除運算,請輸入運算表示式,如:1+2,按回車鍵。\n");
scanf("%lf%c%lf%c",&a,&ch,&b,&ch1);
switch(ch)
{
case "+":
c=a+b;
printf("%lf+%lf=%.10lf\n",a,b,c);
break;
case "-":
c=a-b;
printf("%lf-%lf=%.10lf\n",a,b,c);
break;
case "*":
c=a*b;
printf("%lf*%lf=%.10lf\n",a,b,c);
break;
case "/":
c=a/b;
printf("%lf/%lf=%.10lf\n",a,b,c);
break;
default:
printf("輸入表示式錯誤或該計算器不具備 %ch功能\n",ch);
}
}