Equation Solver
Source Code
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int total = 0;
string inp = "";
cin >> total;
cin >> inp;
while(inp != "="){
if(inp == "P"){
cin >> inp;
if(inp == "=") break;
total += stoi(inp);
}else{
cin >> inp;
if(inp == "=") break;
total -= stoi(inp);
}
cin >> inp;
}
cout << total << "\n";
return 0;
}