Taking multiple inputs in a single linePosted: December 27, 2011
So most of the programming problems given in sites like code jam or code chef ask for taking multiple inputs (that are integers in a single line). So I did I bit of research on it (googled it, actually).
I got recommendations like, take the imputs as a single string and then parse the strinf into respective integer inputs. So I spent my hole morning doing that, obviosuly there were errors, I tried to sownload missing C libraries, learnt some new functinos in C++. A pretty neat code on parsing the string into words that I cam across was:
using namespace std;
string s(“Somewhere down the road”);
iss >> sub;
cout << “Substring: ” << sub << endl;
} while (iss);
But after much head scratching I found another solution to the problem:
cin>>a>>b and it worked!