2 条题解
-
0
#include<bits/stdc++.h> using namespace std; int main(){ int a1,a2; char c; cin >> a1 >> a2; cin >> c; if(a2 == 0 && c == '/'){ cout << "Divided by zero!"; return 0; } if (c == '+') cout << a1 + a2; if (c == '-') cout << a1 - a2; if (c == '*') cout << a1 * a2; if (c == '/') cout << a1 / a2; if (c != '+' && c != '-' && c != '*' && c != '/') cout << "Invalid operator!"; return 0; }
-
-1
#include<bits/stdc++.h> using namespace std; int main(){ int a1,a2; char c; cin >> a1 >> a2; cin >> c; if(a2 == 0 && c == '/'){ cout << "Divided by zero!"; return 0; } if (c == '+') cout << a1 + a2; if (c == '-') cout << a1 - a2; if (c == '*') cout << a1 * a2; if (c == '/') cout << a1 / a2; if (c != '+' && c != '-' && c != '*' && c != '/') cout << "Invalid operator!"; return 0; }
- 1
信息
- ID
- 48
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- 3
- 标签
- (无)
- 递交数
- 107
- 已通过
- 57
- 上传者