Guest User

Untitled

a guest
Jul 18th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. // @eyny@Force[TW]@
  2. #include "forcetw20101225.h"
  3. //
  4. CStrPmt::CStrPmt(string str)
  5. {
  6. this->m_str = str;
  7. this->m_pmt.clear();
  8. }
  9. CStrPmt::~CStrPmt(void)
  10. {
  11. this->m_str.clear();
  12. this->m_pmt.clear();
  13. }
  14. void CStrPmt::permute(void)
  15. {
  16. string buffer = this->m_str;
  17. string:: iterator pBegin = buffer.begin();
  18. string:: iterator pEnd = buffer.end();
  19. sort(pBegin, pEnd, lessComp);
  20. this->m_pmt.push_back(buffer);
  21. while ( next_permutation(pBegin, pEnd) )
  22. {
  23. this->m_pmt.push_back(string(pBegin, pEnd));
  24. }
  25. }
  26. void CStrPmt::print(void)
  27. {
  28. for (vStrPmt::iterator it = this->m_pmt.begin(); it != this->m_pmt.end(); it ++)
  29. {
  30. cout << (*it) << endl;
  31. }
  32. }
  33. bool greatComp(char ch1, char ch2)
  34. {
  35. return ch1 > ch2;
  36. }
  37. bool lessComp(char ch1, char ch2)
  38. {
  39. return ch1 < ch2;
  40. }
Add Comment
Please, Sign In to add comment