The full array of STL (1) has not been continued.

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.