#include<bits/stdc++.h>
using namespace std;
int a[10];
int main()
{
for(int i =1 ;i <= 4 ; i++)
{
a[i]=i;
}
bool tag =true;
while(tag)
{
for(int i=1;i<=4;i++)
{
cout<<a[i]<<' ';
}
cout<< '\n';
tag =next_permutation( a + 1,a + 1 + 4);//全排列是直接修改数组中的元素
}
return 0;
}
库函数:
next_permutation(),如果还有全排列则返回1,反之为0;
prev_permutation()
451

被折叠的 条评论
为什么被折叠?



