Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // @eyny@Force[TW]@
- #include "forcetw20101225.h"
- //
- CStrPmt::CStrPmt(string str)
- {
- this->m_str = str;
- this->m_pmt.clear();
- }
- CStrPmt::~CStrPmt(void)
- {
- this->m_str.clear();
- this->m_pmt.clear();
- }
- void CStrPmt::permute(void)
- {
- string buffer = this->m_str;
- string:: iterator pBegin = buffer.begin();
- string:: iterator pEnd = buffer.end();
- sort(pBegin, pEnd, lessComp);
- this->m_pmt.push_back(buffer);
- while ( next_permutation(pBegin, pEnd) )
- {
- this->m_pmt.push_back(string(pBegin, pEnd));
- }
- }
- void CStrPmt::print(void)
- {
- for (vStrPmt::iterator it = this->m_pmt.begin(); it != this->m_pmt.end(); it ++)
- {
- cout << (*it) << endl;
- }
- }
- bool greatComp(char ch1, char ch2)
- {
- return ch1 > ch2;
- }
- bool lessComp(char ch1, char ch2)
- {
- return ch1 < ch2;
- }
Add Comment
Please, Sign In to add comment