在键盘上任意输入两个数字和一个运算符(+,-,*,/)的程序

如题所述

第1个回答  2011-01-10
#include<iostream>
using namesapce std;
int main()
{
double i,j,result;
char op;
cout<<"input the first number:\n";
cin>>i;
cout<<"input the second number:\n";
cin>>j;
cout<<"input the operator:\n";
cin>>op;
switch (op)
{
case '+'
result=i+j;break;
case '/'
if (0!=j)
result=i/j;break;
else
cout<<"除数不能为0";
case '-'
result=i-j;break;
case '*'
result=i*j;break;
cout<<"result is:"<<result<<endl;
}
return 0;
}本回答被网友采纳
第2个回答  2011-01-09
建议你用极品五笔输入法的软键盘。就可以选用符号了。
相似回答