额... ...有你这么写的吗???
除数也不能为0
#include
void main()
{
float x,y,z,e; //怎么定义的???
char c,d;
printf ("x=");
scanf ("%f",&x);
printf ("y=");
scanf ("%f",&y);
printf ("z=");
scanf ("%f/n",&z);
scanf(" %c %c",&c,&d); //两个%c前均有空格,向你那种写法,输入的时候回车或空格都会被字符函数getchar吃掉!!!
switch(c)
{
case'+':e=x+y;break;
case'-':e=x-y;break;
case'*':e=x*y;break;
case'/':e=x/y;break;
}
switch(d)
{
case'+':printf("%f+%f=%f\n",e,z,e+z);break;
case'-':printf("%f+%f=%f\n",e,z,e-z);break;
case'*':printf("%f+%f=%f\n",e,z,e*z);break;
case'/':printf("%f+%f=%f\n",e,z,e/z);break;
}
}
#include
void main()
{
float x,y,z,e; //应该float型的,对应scanf读入要用%f
char c,d;
printf (