求大神告知哪里错了???
#include<stdio.h>intmain(){inta,b;charop;printf("Pleaseentertheexpression");scanf("%d...
#include <stdio.h>
int main()
{
int a,b;
char op;
printf("Please enter the expression");
scanf("%d%c%d",&a,&op,&b);
switch(op);
{
case '+': printf("%d+%d=%d\n",a,b,a+b);break;
case '-': printf("%d-%d=%d\n",a,b,a-b);break;
case '*': printf("%d*%d=%d\n",a,b,a*b);break;
case '/': if(b!=0) printf("%d/%d=%d\n",a,b,a/b);break;
else printf("b=0\n");
break;
default:break;
}
return 0;
} 展开
int main()
{
int a,b;
char op;
printf("Please enter the expression");
scanf("%d%c%d",&a,&op,&b);
switch(op);
{
case '+': printf("%d+%d=%d\n",a,b,a+b);break;
case '-': printf("%d-%d=%d\n",a,b,a-b);break;
case '*': printf("%d*%d=%d\n",a,b,a*b);break;
case '/': if(b!=0) printf("%d/%d=%d\n",a,b,a/b);break;
else printf("b=0\n");
break;
default:break;
}
return 0;
} 展开
2个回答
展开全部
#include <stdio.h>
int main()
{
int a,b;
char op;
printf("Please enter the expression");
scanf("%d%c%d",&a,&op,&b);
switch(op) //去掉最后分号;
{
case '+': printf("%d+%d=%f\n",a,b,a+b);break;
case '-': printf("%d-%d=%d\n",a,b,a-b);break;
case '*': printf("%d*%d=%d\n",a,b,a*b);break;
case '/': if(b!=0) printf("%d/%d=%f\n",a,b,(float)a/b);//去掉最后的break;因为if语句还没写完
else printf("b=0\n");
break;
default:break;
}
return 0;
}
int main()
{
int a,b;
char op;
printf("Please enter the expression");
scanf("%d%c%d",&a,&op,&b);
switch(op) //去掉最后分号;
{
case '+': printf("%d+%d=%f\n",a,b,a+b);break;
case '-': printf("%d-%d=%d\n",a,b,a-b);break;
case '*': printf("%d*%d=%d\n",a,b,a*b);break;
case '/': if(b!=0) printf("%d/%d=%f\n",a,b,(float)a/b);//去掉最后的break;因为if语句还没写完
else printf("b=0\n");
break;
default:break;
}
return 0;
}
展开全部
#include <stdio.h>
int main()
{
int a,b;
char op;
printf("Please enter the expression");
scanf("%d%c%d",&a,&op,&b);
if(0==b) //b==0特殊情况应该在最开始判断
{
printf("ERROR\n");
return 0;
}
switch(op) //此处没有分号
{
case '+': printf("%d+%d=%d\n",a,b,a+b);break;
case '-': printf("%d-%d=%d\n",a,b,a-b);break;
case '*': printf("%d*%d=%d\n",a,b,a*b);break;
case '/': printf("%d/%d=%d\n",a,b,a/b);break;
default:break;
}
return 0;
}
int main()
{
int a,b;
char op;
printf("Please enter the expression");
scanf("%d%c%d",&a,&op,&b);
if(0==b) //b==0特殊情况应该在最开始判断
{
printf("ERROR\n");
return 0;
}
switch(op) //此处没有分号
{
case '+': printf("%d+%d=%d\n",a,b,a+b);break;
case '-': printf("%d-%d=%d\n",a,b,a-b);break;
case '*': printf("%d*%d=%d\n",a,b,a*b);break;
case '/': printf("%d/%d=%d\n",a,b,a/b);break;
default:break;
}
return 0;
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询