Advertisement
Guest User

Untitled

a guest
Jan 13th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4.  
  5. using namespace std;
  6.  
  7. const string alpha = "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM";
  8. //const string alpha = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
  9.  
  10. vector<string> parse (string str)
  11. {
  12. int pos;
  13. vector<string> vec;
  14.  
  15. while ((pos = str.find(',')) != string::npos)
  16. {
  17. vec.push_back(str.substr(0, pos));
  18. str = str.substr(pos + 1);
  19. }
  20. vec.push_back(str);
  21. return vec;
  22. }
  23.  
  24. void choose_words(vector<string> vec, int n)
  25. {
  26. vector<string> ans;
  27. for (int i = 0; i < vec.size(); ++i)
  28. {
  29. if(vec[i].length() >= n)
  30. ans.push_back(vec[i]);
  31. }
  32. for (int i = 0; i < ans.size() - 1; ++i)
  33. cout << ans[i] << ',';
  34. cout << ans[ans.size() - 1];
  35.  
  36. }
  37.  
  38. int main()
  39. {
  40. string str;
  41. getline(cin, str);
  42. int n;
  43. cin >> n;
  44.  
  45. vector<string> arr_of_words = parse(str);
  46. /*for (int i = 0; i < arr_of_words.size(); ++i)
  47. cout << arr_of_words[i] << endl;*/
  48.  
  49. choose_words(arr_of_words, n);
  50.  
  51. cout << endl;
  52.  
  53. return 0;
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement