NIKOLAY_TETUS

nikita

Jun 6th, 2022
1,121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.15 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4. #include <algorithm>
  5.  
  6. using namespace std;
  7.  
  8. string manipulate(vector<string> arr)
  9. {
  10.     string output;
  11.  
  12.     for (auto i: arr)
  13.         if (count_if(i.begin(), i.end(), [](char a){return isupper(a);}) <= 1)
  14.             output += i + '.';
  15.  
  16.     return output;
  17. }
  18.  
  19. //Функция шоб выводить вектор. Возможн потом пригодится
  20. template <typename T>
  21. void printVector(vector<T> arr)
  22. {
  23.     for (auto i: arr)
  24.         cout << i << endl;
  25. }
  26.  
  27. vector<string> mySplit(string str)
  28. {
  29.     string bufStr = str;
  30.     string delimiter = ".";
  31.  
  32.     vector<string> outputArr;
  33.  
  34.     size_t pos = 0;
  35.     string token;
  36.     while ((pos = bufStr.find(delimiter)) != string::npos)
  37.     {
  38.         token = bufStr.substr(0, pos);
  39.         outputArr.push_back(token);
  40.         bufStr.erase(0, pos + delimiter.length());
  41.     }
  42.  
  43.     outputArr.push_back(bufStr);
  44.  
  45.     return outputArr;
  46. }
  47.  
  48. int main()
  49. {
  50.     string test = "Hello world. There is a lotus. Somewehere on the Earth.";
  51.  
  52.     vector<string> buf = mySplit(test);
  53.  
  54.     cout << manipulate(buf);
  55.  
  56.  
  57.     return 0;
  58. }
Advertisement
Add Comment
Please, Sign In to add comment