Skip to content

Instantly share code, notes, and snippets.

@mukulrawat1986
Created May 8, 2014 19:36
Show Gist options
  • Save mukulrawat1986/55a9ed8d9535f441a861 to your computer and use it in GitHub Desktop.
Save mukulrawat1986/55a9ed8d9535f441a861 to your computer and use it in GitHub Desktop.
Snippets for competitive programming for manipulating inputs
// convert an integer to string
string intToString (int a){
ostringstream os(a);
os<<a;
return os.str();
}
// convet a string to a single int
int stringToInt(string s){
int a;
istringstream is(s);
is>>a;
return a;
}
// Comvert a string input to a vector of int
// inputs like '1 3 4 5 6 7 8'
void stringToInt(string s, vector <int> & a){
int temp;
istringstream is(s);
while(is>>temp)
a.push_back(temp);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment