Skip to content

Instantly share code, notes, and snippets.

@lazycipher
Created May 5, 2019 10:39
Show Gist options
  • Save lazycipher/2c5e40f01fd832dd00401d72eadc2704 to your computer and use it in GitHub Desktop.
Save lazycipher/2c5e40f01fd832dd00401d72eadc2704 to your computer and use it in GitHub Desktop.
StringStream HackerRank Practice C++
#include <sstream>
#include <vector>
#include <iostream>
using namespace std;
vector<int> parseInts(string str) {
stringstream s(str);
vector<int> arr;
int a;
char ch;
while(s >> a){
arr.push_back(a);
s >> ch;
}
return arr;
}
int main() {
string str;
cin >> str;
vector<int> integers = parseInts(str);
for(int i = 0; i < integers.size(); i++) {
cout << integers[i] << "\n";
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment