我不被允许使用 mod。我认为它不起作用,因为我使用的是双打;有没有解决的办法?--- 评论区无法正常工作
void displayResults(double num1, char oper, double num2)
{
switch(oper)
{
case '+' :
cout << num1 << "+" << num2 << "=" << (num1+num2) << endl;
break;
case '-' :
cout << num1 << "-" << num2 << "=" << (num1-num2) << endl;
break;
case '*' :
cout << num1 << "*" << num2 << "=" << (num1*num2) << endl;
break;
case '/' :
if ( num1==0 || num2==0)
cout <<"A number divided by 0 or divided into 0 is always 0"<< endl;
else
cout << num1 << "/" << num2 << "=" << (num1/num2) /*+ (num1%num2) */ << endl;
break;
// case '%' :
// cout << num1 << "%" << num2 << "=" << (num1%num2);
//break;
}
}