Advertisement
Neveles

Untitled

Oct 23rd, 2019
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <cstring>
  4.  
  5. using namespace std;
  6.  
  7. string excludedStr(const string &str, const string &strx) // const string &str
  8. {
  9. setlocale(LC_ALL, "rus");
  10.  
  11. string newStr = "";
  12. for (int i = 0; i < str.size(); i++)
  13. {
  14. int j = 0;
  15. while ((str[i] != strx[j]) && (j != strx.size()))
  16. ++j;
  17. if (j == strx.size())
  18. newStr += str[i];
  19. }
  20. return newStr;
  21. }
  22.  
  23. char *excludedStr(const char str[], const char strx[])
  24. {
  25. setlocale(LC_ALL, "rus");
  26.  
  27. int k = 0;
  28. char *newChar = new char[255];
  29. for (int i = 0; str[i] != '\0'; i++)
  30. {
  31. int j = 0;
  32. while ((str[i] != strx[j]) && (j != strlen(strx)))
  33. ++j;
  34. if (j == strlen(strx))
  35. {
  36. newChar[k] = str[i];
  37. k++;
  38. }
  39. }
  40. newChar[k] = '\0';
  41. return newChar;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement