NYOJ 366 D的小L
地址:http://acm.nyist.net/JudgeOnline/problem.php?pid=366
方法;用next_permutation(pɝmjʊ'teʃə)来求解,递归调用代码
1 #include<stdio.h> 2 #include<algorithm> 3 using namespace std; 4 int main() 5 { 6 int a[]={1,2,3,4,5,6,7,8,9}; 7 int k,n,i; 8 scanf("%d",&k); 9 while(k--) 10 { 11 scanf("%d",&n); 12 do 13 { 14 for(i=0;i<n;i++) 15 { 16 printf("%d",a[i]); 17 } 18 printf("\n"); 19 } 20 while(next_permutation(a,a+n)); 21 } 22 return 0; 23 } 24