Untitled
unknown
c_cpp
a month ago
785 B
1
Indexable
Never
#include <iostream> #include <string> using namespace std; int main() { int x; cin >> x; float result = 0; char ss; cin >> ss; int y; cin >> y; while(ss!='x'){ if (y == 0) { cout << "error"; break; } switch (ss) { case('+'): result = x + y; cin >> ss; if (ss == 'x') { cout << result << endl; } break; case('-'): result = x - y; if (ss == 'x') { cout << result << endl; } break; case('/'): result = float(x) / y; if (ss == 'x') { cout << result << endl; } break; case('*'): result = x * y; if (ss == 'x') { cout << result << endl; } break; default: break; } if (ss == '@') { x = result; cin >> ss; cin >> y; } } }