Advertisement
Guest User

Untitled

a guest
Jan 13th, 2017
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 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.  
  9. vector<string> parse (string str)
  10. {
  11. int pos;
  12. vector<string> vec;
  13.  
  14. while (pos = str.find_first_not_of(alpha) != string::npos)
  15. {
  16. vec.push_back(str.substr(0, pos));
  17. str = str.substr(pos +1);
  18. }
  19. vec.push_back(str);
  20. return vec;
  21. }
  22.  
  23. int max_length (vector<string> vec)
  24. {
  25. int max_length = 0;
  26. for (int i = 0; i < vec.size(); ++i)
  27. {
  28. if(max_length < vec[i].length())
  29. max_length = vec[i].length();
  30. }
  31. return max_length;
  32. }
  33.  
  34. int main()
  35. {
  36. string str;
  37. //cin >> str;
  38. getline(cin, str);
  39.  
  40. int result = 0;
  41.  
  42. vector<string> arr_of_words = parse(str);
  43. result = max_length(arr_of_words);
  44.  
  45. cout << result << endl;
  46.  
  47. return 0;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement