So i know how to do permutation when you have numbers listed as 1,2,3,4 but how do u write a program where the input file is just "15 , 10"and you have to make 10 permutations for 1-15? I have to do it using a source set
All you have to do is generate an array with the numbers in the range 1-15, then pass that array to the backtracking function which does the permutations. In the backtracking algorithm, simply add a counter and when it reaches 10, use return/break (depending on your implementation recursive/iterative).
Well, you can put here the pseudocode for the 1,2,3,4 permutation (as you mentioned, you know how to do that), and I'll just tell you where to make changes. Actually, if I had more time right now, I would write it myself, but I'm a little busy, sorry for that.
There are numerous tutorials on the internet, including one on this site, explaining how to use files in C++. As long as you don't use .open(), .close(), or .eof(), you should be fine with any tutorial.
If you are using vectors can you use the built in std::next_permutation or do you have to use your own? Either way just get the next permutation 10 times and you are good to go.
i am not sure if i am doing this right
void permutaion(const vector<int> &now,
vector<int> &next)
{
int size=now.size();
if(size>0)
{
for(int cnt=0; cnt<size;++cnt)
{
vector<int> vt;