STL解法
#include<bits/stdc++.h>
using namespace std;
int main()
{
vector<int> test(8);
for(int i=0; i<8; ++i)
{
test[i]=i+1;
}
do
{
for(int i=0; i<8; ++i)
{
if( 7!=i )
{
printf("%d ",test[i]);
}
else
{
printf("%d\n",test[i]);
}
}
}while( next_permutation( test.begin(), test.end()) );
return 0;
} 
京公网安备 11010502036488号