Untitled
unknown
c_cpp
2 years ago
673 B
4
Indexable
#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; cout << result << endl; break; case('-'): result = x - y; cout << result << endl; break; case('/'): result = float(x) / y; cout << result << endl; break; case('*'): result = x * y; cout << result << endl; break; default: break; } cin >> ss; if (ss == '@') { x = result; cin >> ss; cin >> y; } } }
Editor is loading...