Thanks, that fixed it.
I've been working to convert that method from using strings to lists and sets. Originally I had a ton of errors, but now I've managed to fix a few of them. However, I seem to be stuck now. Here is my code:
Code:
#include <string>
#include <iostream>
#include <set>
#include <list>
using namespace std;
void string_permutation(set<int>& orig, list<int>& perm )
{ // line 10
if( orig.empty() )
{
list<int>::iterator theIterator;
for(theIterator = perm.begin(); theIterator != perm.end(); theIterator++)
{
cout << *theIterator << "\n";
}
return;
}
for(int i = 0; i < orig.size(); i++) // line 21
{
list<int> orig2 = orig;
orig2.erase(i,1); // line 25
list<int> perm2 = perm;
perm2.push_front(orig.find(i)); // line 29
string_permutation(orig2,perm2); // line 31
}
}
int main()
{
int myInts[] = {1, 3, 2, 4};
set<int> orig(myInts, myInts+4);
list<int> perm;
string_permutation(orig, perm);
system("Pause");
return 0;
}
And the compiler errors:
Code:
21 permutation.cpp [Warning] comparison between signed and unsigned integer expressions
23 permutation.cpp conversion from `std::set<int, std::less<int>, std::allocator<int> >' to non-scalar type `std::list<int, std::allocator<int> >' requested
25 permutation.cpp invalid conversion from `int' to `std::_List_node_base*'
25 permutation.cpp initializing argument 1 of `std::_List_iterator<_Tp>::_List_iterator(std::_List_node_base*) [with _Tp = int]'
25 permutation.cpp invalid conversion from `int' to `std::_List_node_base*'
25 permutation.cpp initializing argument 1 of `std::_List_iterator<_Tp>::_List_iterator(std::_List_node_base*) [with _Tp = int]'
29 permutation.cpp no matching function for call to `std::list<int, std::allocator<int> >::push_front(std::_Rb_tree_const_iterator<int>)'
note C:\Applications\Dev-Cpp\include\c++\3.4.2\bits\stl_list.h:753 candidates are: void std::list<_Tp, _Alloc>::push_front(const _Tp&) [with _Tp = int, _Alloc = std::allocator<int>]
31 permutation.cpp invalid initialization of reference of type 'std::set<int, std::less<int>, std::allocator<int> >&' from expression of type 'std::list<int, std::allocator<int> >'
10 permutation.cpp in passing argument 1 of `void string_permutation(std::set<int, std::less<int>, std::allocator<int> >&, std::list<int, std::allocator<int> >&)'