Input:
The input contains several test cases. The only line of each test case contains a string in the form R+L=J. If the value of a variable is known, such value appears in the string instead the variable itself. Otherwise, the letter that indicate the variable appears normally.
It is guaranteed that exactly two of the three values are known. There is no leading zeros in the given values.
The input is read from standard in (cin).
Output
For each test case, print a single line containing the value of the unknown variable.
-----‐------------------------------------------------------------
I managed to figure it out. I just needed to use:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
#include <iostream>
#include <string>
using namespace std;
int main()
{
while(getline(cin, equation, '+'){
r = equation;
getline(cin, equation, '=');
l = equation;
getline(cin, equation);
j = equation;
//rest of my earlier code, minus the 3 getlines.
}
return 0;
}
|
Thanks for the input. Glad there's people out there willing to help out!
(Btw, just now saw Ganado's post, and that is pretty much what i did, but it took me a while. Wish i had seen this earlier..