Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- #include <stdexcept>
- #include <string>
- #include <vector>
- using namespace std;
- string VratiRijec(int i, string s) {
- string pom;
- for (int j=i; j<s.length(); j++) {
- if (s[j]!=' ')
- pom.push_back(s[j]);
- else
- break;
- }
- return pom;
- }
- vector<string> Fjaa (string s) {
- vector<string> v(0);
- if (s[0]!=' ')
- {
- string pom{VratiRijec(0,s)};
- v.push_back(pom);
- }
- for (int j=1; j<s.length(); j++) {
- string pom_rijec;
- if (s[j-1]==' ' && s[j]!=' ')
- { pom_rijec=VratiRijec(j,s);
- v.push_back(pom_rijec);
- }}
- return v;
- }
- int main () {
- string rec{"Selma je bila ovdje."};
- vector<string>rez{Fjaa(rec)};
- for (string s: rez) cout<<s<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement