STL Topic I: Good ZJ time limit: ten Sec memory limit: MB
submitted: resolution: 17
Submitted State Forum Title Description
One day zj see Xiao Ming unexpectedly sort learn than their own cattle, so out a problem to Xiao Ming, to prove his Bi Xiaoming more bull. The problem is that there is a number n (0<n<10), write 1 to N of the whole arrangement, then xiaoming a bit embarrassed ,,, Smart can you help Xiao Ming rescue?
Input
the first line enters a number n (0<n<10), which indicates that there are n sets of test data. The following n lines enter multiple sets of input data, each set of input data is an integer x (0<x<10)
Output
output all combinations in a specific order.
Specific order: The values in each combination are arranged from small to large, and the combinations are arranged in dictionary order.
Sample input223Sample output1221123132213231312321Tip: There is a fixed library of functions;
#include<iostream>
#include<cmath>
#include<cstring>
#include<algorithm>
using
namespace
std;
int
main()
{
int
i,k,n;
cin>>n;
while
(n--)
{
cin>>k;
int
a[105];
for
(i=0;i<k;i++)
a[i]=i+1;//将数组里面的赋初值。
do
{
for
(i=0;i<k;i++)
cout<<a[i];
cout<<endl;
}
while
(next_permutation(a,a+k));//从数组开始到k的区间,进行全排列,可以自己试试next_permutation()的功能。
return
0;
}
The full array of STL (1) has not been continued.