计算器是生活中的常用物品,接下来让我送上c++的简易计算器代码
#include <iostream>
using namespace std;
int main( ) {
int a,b;
char op;
cin >> a >> op >> b;
if (op == '+') cout << a+b;
if (op == '-') cout << a-b;
if (op == '*') cout << a*b;
if (op == '/') {
if (b == 0) {
cout << "除数为零!";
}
else {
cout << a/b;
}
return 0;
}