对两个整数进行乘除求余。代码在编辑器上显示没问题,但是和答案始终不一致。
#include <iostream>using namespace std;
int main(int argc, char** argv)
{
char sign;
int x,y;
cin>>x>>y;
if(sign='*')
cout<<x<<" * "<<y<<" = "<<x*y<<endl;
else if(sign='/')
cout<<x<<" / "<<y<<" = "<<x/y<<endl;
else if(sign='%')
cout<<x<<" Mod "<<y<<" = "<<x%y<<endl;
else
cout<<"运算符输入错误!"<<endl;
return 0;
}