- 论坛徽章:
- 0
|
先解决排列问题: 编译后用法 echo "yourstring" | mytool, 可以循环排出,直至返回空。
- #include <iostream>
- #include <vector>
- #include <iterator>
- #include <algorithm>
- int main()
- {
- using namespace std;
- typedef vector<char> vec_char;
- vec_char thestr;
- copy(istream_iterator<char>(cin),istream_iterator<char>(),back_insert_iterator<vec_char>(thestr));
- if(next_permutation(thestr.begin(),thestr.end()))
- copy(thestr.begin(),thestr.end(),ostream_iterator<char>(cout));
- else
- return -1;
- return 0;
- }
复制代码
[ 本帖最后由 doctorjxd 于 2007-3-31 11:17 编辑 ] |
|