6 条题解
-
3
#include<bits/stdc++.h> using namespace std; int main() { int a,b; char c; cin>>a>>b>>c; switch(c) { case '+': cout<<a+b; break; case '-': cout<<a-b; break; case '': cout<<ab; break; case '/': if(b!=0) { cout<<a/b; break; } else { cout<<"Divided by zero!"; break; } default: { cout<<"Invalid operator!"; break; }
} return 0; } -
2
#include<bits/stdc++.h> #define yy return 0; using namespace std; int main() { int a,b; char 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=='/') { if(b==0) cout<<"Divided by zero!"; else cout<<a/b; } else cout<<"Invalid operator!"; yy }
-
2
水题
#include<bits/stdc++.h> #define yy return 0; using namespace std; int main() { int a,b; char 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=='/') { if(b==0) cout<<"Divided by zero!"; else cout<<a/b; } else cout<<"Invalid operator!"; yy }
-
1
#include<bits/stdc++.h> using namespace std; int main() { int a,b; char c; cin>>a>>b>>c; switch(c) { case '+': cout<<a+b; break; case '-': cout<<a-b; break; case '*': cout<<a*b; break; case '/': if(b!=0) {cout<<a/b; break; } else cout<<"Divided by zero!"; break; default: cout<<"Invalid operator!"; break; } return 0; }//switch-case语句
-
1
#include<bits/stdc++.h> using namespace std; int main(){ int a,b; char c; cin>>a>>b>>c; if (c=='+') {cout<<(a+b);} else if (c=='-') {cout<<a-b; } else if (c=='') {cout<<ab; } else if (c=='/') {if (b==0) {cout<<"Divided by zero!";} else {cout<<a/b; }} else {cout<<"Invalid operator!"; } return 0; } //自己换行
-
0
#include<bits/stdc++.h> using namespace std; int main() { int a,b; char c; cin>>a>>b>>c; if(c=='+') { cout<<a+b; } else if(c=='-') { cout<<a-b; } else if(c=='') { cout<<ab; } else if(c=='/') { if(b==0) { cout<<"Divided by zero!"; } else { cout<<a/b; } } else { cout<<"Invalid operator!"; } return 0; } 自己换行
- 1
信息
- ID
- 4502
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- 1
- 标签
- (无)
- 递交数
- 135
- 已通过
- 84
- 上传者