man123 @ 2023-05-14 15:23:36
#include<iomanip>
#include <cstring>
#include<cmath>
#include<bits/stdc++.h>
using namespace std;
int main(){
std::ios::sync_with_stdio(false);
std::cin.tie(0);
std::cout.tie(0);
int a,b;
string c;
cin>>a>>b>>c;
if(c=="+"){
cout<<a+b;
}
else if(c=="-"){
cout<<a-b;
}
else if(c=="/"){
cout<<a/b;
}
else if(c=="*"){
cout<<a*b;
}
else if(b==0&&c=="/"){
cout<<"Divided by zero!";
}
else if(c!="+"&&c!="-"&&c!="*"&&c!="/"){
cout<<"Invalid operator!";
}
return 0;
}
by sugawara @ 2023-05-14 15:27:04
这边建议scanf和printf试试
by __jpf__ @ 2023-05-19 13:07:38
@man123
else if(b==0&&c=="/"){
cout<<"Divided by zero!";
}
写到
else if(c=="/"){
cout<<a/b;
}
前面
by xiechengxuan1061862 @ 2023-10-26 14:54:40
你加上了万能头文件,就不用其他头文件了啊?