方法1:
- #include<stdio.h>
- char c[9];
- int x,j,k;
- int main(int i){
- for(i=35280;i--;)
- if(j=i%7,c[j+1]=j+49,!j){
- for(x=7,j=720;x-1;j/=--x)*c=c[x],c[x]=c[k=i/7/j%x+1],c[k]=*c;puts(c+1);
- }
- return 0;
- }
方法2:
- #include<algorithm>
- #include<stdio.h>
- int main(){
- char a[]="1234567";
- do{
- puts(a);
- }
- while(std::next_permutation(a,a+7));
- }
方法3:
- #include<stdio.h>
- main(){
- int i,j,k,t;
- for(i=0;i<7654322;i++){
- t=i;
- j=k=0;
- for(;j<7;j++,t/=10)
- k|=1<<t%10;
- if(k==254)
- printf("%d/n",i);
- }
- }
方法4:
- #include<algorithm>
- #include<stdio.h>
- main(){for(char a[]="1234567";
- puts(a),std::next_permutation(a,a+7););}