#include
#include
using namespace std;
int main()
{
float x,y;
char op;
while(op!='+'&&op!='-'&&op!='/'&&op!='*')
{
system("cls");
cout<<"x:";
cin>>x;
cout<<"y:";
cin>>y;
cout<<"op:";
cin>>op;
}
if(y==0&&op=='/')
{
cout<<"divided by zero.";
return 0;//用return 0一样的
}
cout<<"answer:"<switch(op)
{
case '+':{
cout<break;
}
case '-':{
cout<break;
}
case '*':{
cout<break;
}
case '/':{
cout<break;
}
default:
break;
}
return 0;
}
支持浮点型!
重新输入说明你输入的运算符不对!
可是敲了一会呢...
望加悬赏&采纳!