fork download
  1. const std::set<std::string> badwords =
  2. {
  3. "jebac",
  4. "jeban",
  5. "kurw",
  6. "korwa",
  7. "pierdol",
  8. "pierdal",
  9. "huj",
  10. "choj",
  11. "pizd",
  12. "kutas",
  13. "fuck",
  14. "cipa",
  15. "pedale",
  16. "szmato",
  17. "szmata",
  18. "szmaty",
  19. "szmatko",
  20. "szmatka",
  21. "szmatki",
  22. "zajebie",
  23. "zjeb",
  24. "suka",
  25. "suko",
  26. "suki"
  27. };
  28.  
  29. const std::vector<std::string> badword_sizes =
  30. {
  31. "",
  32. "*",
  33. "**",
  34. "***",
  35. "****",
  36. "*****",
  37. "******",
  38. "*******",
  39. "********",
  40. "*********",
  41. "**********",
  42. "***********",
  43. "************",
  44. "*************",
  45. "**************",
  46. "***************"
  47. };
  48.  
  49. const std::vector<std::pair<std::string,std::string>> PolishReplacement =
  50. {
  51. { "ł", "l" },
  52. { "ą", "a" },
  53. { "ę", "e" },
  54. { "ć", "c" },
  55. { "ż", "z" },
  56. { "ź", "z" },
  57. { "ó", "o" },
  58. { "ś", "s" },
  59. { "ń", "n" }
  60. };
  61.  
  62. void FilterBadWords(std::string& s)
  63. {
  64. std::string str_copy(s);
  65. for (auto replace : PolishReplacement)
  66. boost::ireplace_all(str_copy, replace.first, replace.second);
  67.  
  68. for (auto &badword : badwords)
  69. {
  70. size_t pos = str_copy.find(badword);
  71. size_t size;
  72. while (pos != std::string::npos)
  73. {
  74. size = badword.size();
  75.  
  76. s.replace(pos, pos + size, badword_sizes[size]);
  77. str_copy.replace(pos, pos + size, badword_sizes[size]);
  78.  
  79. pos = str_copy.find(badword);
  80. }
  81. }
  82. }
  83.  
  84. //input: Ty jebany pierdolony chuju szmata pierdolona kurwo kurwa
  85. //output: Ty *****ierdolony c***rwo ****
  86. //expected output: Ty *****y *******ony c***u ****** *******ona ****o ****a
  87.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:1:12: error: 'set' in namespace 'std' does not name a template type
 const std::set<std::string> badwords = 
            ^
prog.cpp:29:12: error: 'vector' in namespace 'std' does not name a template type
 const std::vector<std::string> badword_sizes =
            ^
prog.cpp:49:12: error: 'vector' in namespace 'std' does not name a template type
 const std::vector<std::pair<std::string,std::string>> PolishReplacement =
            ^
prog.cpp:62:26: error: variable or field 'FilterBadWords' declared void
 void FilterBadWords(std::string& s)
                          ^
prog.cpp:62:21: error: 'string' is not a member of 'std'
 void FilterBadWords(std::string& s)
                     ^
prog.cpp:62:34: error: 's' was not declared in this scope
 void FilterBadWords(std::string& s)
                                  ^
stdout
Standard output is empty