2 条题解
-
212237余傲寒 (12237余傲寒) LV 8 @ 2021-11-22 21:09:23
#include <iostream>
using namespace std;
int main( )
{
int a,b;char c;
cin>>a>>b;
cin>>c;
switch(c)
{
case '+':cout<<a+b;break;
case '-':cout<<a-b;break;
case '*':cout<<a*b;break;
case '/':if(b==0)cout<<"Divided by zero!";else cout<<a/b;break;
default:cout<<"Invalid operator!";
}
} -
12021-12-16 19:17:53@
#include <iostream> #include <cstdio> using namespace std; int main() { int a, b; char op; cin >> a >> b >> op; switch (op) { case '+': cout << a + b; break; case '-': cout << a - b; break; case '*': cout << a * b; break; case '/': if (b == 0) { cout << "Divided by zero!"; } else { cout << a / b; } break; default: cout << "Invalid operator!"; } return 0; }
- 1
信息
- ID
- 2348
- 难度
- 3
- 分类
- (无)
- 标签
- 递交数
- 142
- 已通过
- 71
- 通过率
- 50%
- 被复制
- 2
- 上传者