fork(2) download
  1. #include <iostream>
  2. #include <vector>
  3. #include <algorithm>
  4. #include <string>
  5. using namespace std;
  6. std::string postfix = "ski";
  7. string transformers(std::string &s){
  8. std::string buf = s;
  9. size_t find = s.find(postfix, s.length() - postfix.length());
  10. if(find != std::string::npos){
  11. buf.replace(1, find-1,buf.length() - postfix.length() - 1, '*');
  12. return buf;
  13. }
  14. return buf;
  15. }
  16. int main()
  17. {
  18. std::vector<string> ziomy;
  19. ziomy.push_back("Kowalski");
  20. ziomy.push_back("Wachowski");
  21. ziomy.push_back("Pejowski");
  22. ziomy.push_back("Andrzejewski");
  23. ziomy.push_back("Zdzislawsko");
  24. ziomy.push_back("Andrzejek");
  25. std::transform(ziomy.begin(), ziomy.end(), ziomy.begin(), transformers);
  26. for(auto it : ziomy){
  27. std::cout << it << endl;
  28. }
  29. }
  30.  
Success #stdin #stdout 0s 3232KB
stdin
Standard input is empty
stdout
K****ski
W*****ski
P****ski
A********ski
Zdzislawsko
Andrzejek