找不到错误,求指导
#include<stdio.h>int main()
{
double a,b;
char c;
printf("please input expression:a+(-,*,/)b\n");
scanf("%f%c%f" ,&a,&c,&b);
switch(c)
{
case '+':
printf("%1f\n",a+b);
break;
case '-':
printf("%1f\n",a-b);
break;
case '*':
printf("%1f\n",a*b);
break;
case '/':
printf("%1f\n",a/b);
break;
default :
printf("input error\n");
}
}
运行
please input expression:a+(-,*,/)b
2.0+3.0
0.000000
Process returned 0 (0x0) execution time : 9.756 s
Press any key to continue. #include<stdio.h>
int main(void)
{
double a , b ;
char c ;
printf("please input expression a +(-,*,/)b : ");
scanf("%lf %c %lf" , & a , & c , & b) ;
switch(c) {
case '+': printf("%lf\n" , a + b) ; break ;
case '-': printf("%lf\n" , a - b) ; break ;
case '*': printf("%lf\n" , a * b) ; break ;
case '/': printf("%lf\n" , a / b) ; break ;
default : printf("input error\n") ;
}
} scanf("%lf%c%lf" ,&a,&c,&b);
页:
[1]