#include <iostream>
using std::cout;
using std::endl;
using std::cin;
int main()
{
int lhs , rhs , result = 0;
char oper;
cout << "Please enter an equation [a][sign][b] ex: ( 10 + 2 ):" << endl;
cin >> lhs >> oper >> rhs;
switch ( oper )
{
case '+':
result = lhs + rhs;
break;
case '-':
result = lhs - rhs;
break;
case '*':
result = lhs * rhs;
break;
case '/':
if( rhs == 0 )
cout << "Error: Can't divide by 0" << endl;
else
result = lhs / rhs;
break;
default:
cout << "Invalid operation" << endl;
}
cout << lhs << ' ' << oper << ' ' << rhs << " = " << result << endl;
return ( 0 );
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKdXNpbmcgc3RkOjpjb3V0Owp1c2luZyBzdGQ6OmVuZGw7CnVzaW5nIHN0ZDo6Y2luOwoKaW50IG1haW4oKQp7CiAgICBpbnQgbGhzICwgcmhzICwgcmVzdWx0ID0gMDsKICAgIGNoYXIgb3BlcjsKCiAgICBjb3V0IDw8ICJQbGVhc2UgZW50ZXIgYW4gZXF1YXRpb24gW2FdW3NpZ25dW2JdIGV4OiAoIDEwICsgMiApOiIgPDwgZW5kbDsKICAgIGNpbiA+PiBsaHMgPj4gb3BlciA+PiByaHM7CgogICAgc3dpdGNoICggb3BlciApCiAgICB7CiAgICAgICAgY2FzZSAnKyc6CiAgICAgICAgICAgIHJlc3VsdCA9IGxocyArIHJoczsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAnLSc6IAogICAgICAgICAgICByZXN1bHQgPSBsaHMgLSByaHM7IAogICAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICcqJzogCiAgICAgICAgICAgIHJlc3VsdCA9IGxocyAqIHJoczsgCiAgICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgJy8nOiAKICAgICAgICAgICAgaWYoIHJocyA9PSAwICkgCiAgICAgICAgICAgICAgICBjb3V0IDw8ICJFcnJvcjogQ2FuJ3QgZGl2aWRlIGJ5IDAiIDw8IGVuZGw7CiAgICAgICAgICAgIGVsc2UgCiAgICAgICAgICAgICAgICByZXN1bHQgPSBsaHMgLyByaHM7IAogICAgICAgICAgICBicmVhazsKICAgICAgICBkZWZhdWx0OiAKICAgICAgICAgICAgY291dCA8PCAiSW52YWxpZCBvcGVyYXRpb24iIDw8IGVuZGw7CiAgICB9CgogICAgY291dCA8PCBsaHMgPDwgJyAnIDw8IG9wZXIgPDwgJyAnIDw8IHJocyA8PCAiID0gIiA8PCByZXN1bHQgPDwgZW5kbDsKCiAgICByZXR1cm4gKCAwICk7Cn0=