this would be in the daniweb code snippet section.
iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439
iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439
~s.o.s~
Failure as a human
11,938 posts since Jun 2006
Reputation Points: 3,281
Solved Threads: 733
Not what I am looking for, look at my first post.
So, your example don't even make sense
0 0 0
0 0 1
0 0 2
0 1 0
0 1 1
0 1 2
0 2 0
0 2 1
0 2 2
1 0 0
1 0 1 <- Why the repeat
1 0 1 <-Why the repeat
1 1 1
In fact your example doesn't even exhibit behaviour you would expect when using the word 'permutation'
iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439
Ok, so do you mean the mathematical definition of the word combination.
Or are you going to change your mind again.
iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439
In fact your example doesn't even exhibit behaviour you would expect when using the word 'permutation'
Hehe, looks like we are not the only ones asking him this question.
There are others out there....
~s.o.s~
Failure as a human
11,938 posts since Jun 2006
Reputation Points: 3,281
Solved Threads: 733
iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439
Yes so your example neither generates permuations or combinations. HAve you realised this yet?
#include <iostream>
using namespace std;
int main()
{
char crap[100] = "012";
for ( int a = 0; a < 3; a++ )
{
for ( int b = 0; b < 3; b++ )
{
for ( int c = 0; c < 3; c++ )
{
cout << crap[a] <<" "<<crap[b]<<" "<<crap[c];
cout <<"\n";
}
}
}
cin.get();
}
output:
0 0 0
0 0 1
0 0 2
0 1 0
0 1 1
0 1 2
0 2 0
0 2 1
0 2 2
1 0 0
1 0 1
1 0 2
1 1 0
1 1 1
1 1 2
1 2 0
1 2 1
1 2 2
2 0 0
2 0 1
2 0 2
2 1 0
2 1 1
2 1 2
2 2 0
2 2 1
2 2 2
Essentially what you are looking for is something that simulates an arbitary number of nested loops using tail recursion. http://people.cs.uchicago.edu/~jhr/papers/2002/hosc-lcps.pdf
iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439