You are viewing a single comment's thread. Return to all comments →
without using the sstream #include<iostream> #include<string> #include<vector> using namespace std; vector<int> pras(string str){ vector<int> point; vector<int> point2; point.push_back(0); for(int i=0;i<str.length();i++){ if(str.find(",",i)+1 == 0){ break; } point.push_back(str.find(",",i)+1); } for(int i =0;i<point.size()-1;i++){ if(point[i] != point[i+1]){ point2.push_back(point[i]); } } point2.push_back(point[point.size()-1]); for(int i =0;i<point2.size()-1;i++){ point[i] = stoi(str.substr(point2[i],point2[i+1]-point2[i]-1)); } point[point2.size()-1] = stoi(str.substr(point2[point2.size()-1])); point.resize(point2.size()); return point; } int main(){ string str; cin>>str; vector<int> data = pras(str); for(int i =0; i<data.size();i++){ cout<<data[i]<<endl; } return 0; }
Seems like cookies are disabled on this browser, please enable them to open this website
StringStream
You are viewing a single comment's thread. Return to all comments →