Advertisement
sellmmaahh

prva-parc-2012-zad4-String

Aug 1st, 2015
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.82 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <stdexcept>
  4. #include <string>
  5. #include <vector>
  6.  
  7. using namespace std;
  8.  
  9. string VratiRijec(int i, string s) {
  10.     string pom;
  11.     for (int j=i; j<s.length(); j++) {
  12.     if (s[j]!=' ')
  13.         pom.push_back(s[j]);
  14.         else
  15.             break;
  16.     }
  17.     return pom;
  18. }
  19.  
  20. vector<string> Fjaa (string s) {
  21.     vector<string> v(0);
  22.     if (s[0]!=' ')
  23.     {
  24.        string pom{VratiRijec(0,s)};
  25.         v.push_back(pom);
  26.     }
  27.     for (int j=1; j<s.length(); j++) {
  28.             string pom_rijec;
  29.     if (s[j-1]==' ' && s[j]!=' ')
  30.     { pom_rijec=VratiRijec(j,s);
  31.     v.push_back(pom_rijec);
  32.     }}
  33.     return v;
  34. }
  35. int main () {
  36.     string rec{"Selma je bila ovdje."};
  37.     vector<string>rez{Fjaa(rec)};
  38.     for (string s: rez) cout<<s<<endl;
  39.     return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement