From 39213653d26f7afa97740642e7f2061555492770 Mon Sep 17 00:00:00 2001 From: DiptanshuG <78592980+DiptanshuG@users.noreply.github.com> Date: Sat, 23 Oct 2021 01:51:31 +0530 Subject: [PATCH] create stringstream.cpp added 1 solution --- C++/stringstream.cpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 C++/stringstream.cpp diff --git a/C++/stringstream.cpp b/C++/stringstream.cpp new file mode 100644 index 0000000..ed97696 --- /dev/null +++ b/C++/stringstream.cpp @@ -0,0 +1,34 @@ +#include +#include +#include +using namespace std; + +vector parseInts(string str) +{ + // Complete this function + stringstream ss(str); + vector result; + char ch; + int tmp; + + while (ss >> tmp) + { + result.push_back(tmp); + ss >> ch; + } + + return result; +} + +int main() +{ + string str; + cin >> str; + vector integers = parseInts(str); + for(int i = 0; i < integers.size(); i++) + { + cout << integers[i] << "\n"; + } + + return 0; +}