The example of this algorithm is taken from the book I'm learning from.
It compiles but won't run. Can anyone see what's wrong?
//output is meant to be:-
ABDC ACBD ACDB etc ..to ABCD ie(.until all 24 combinations
are printed.)
Appreciate any thoughts.
It compiles but won't run. Can anyone see what's wrong?
Code:
#include<iostream>
#include<algorithm>
//have also included <cmath> and <cstdlib> to no affect.
using namespace std;
int main()
{
char* s="ABCD";
for(int i=0;i<24;i++)
{ next_permutation(s,s+4);
cout<<(i%8?'\t':'\n')<<s;
}
system("pause");
return 0;
}
ABDC ACBD ACDB etc ..to ABCD ie(.until all 24 combinations
are printed.)
Appreciate any thoughts.
Comment