D's small l

Source: Internet
Author: User
D's small l


One day, TC went to the ACM's Xiao L to play with the Three Kingdoms, but this would be a little busy. I don't want to play with Kuang, but I'm afraid of being angry, at this time, Xiao l gave me a question to solve (Xiao L is very D), there is a number of N (0 <n <10), write a full arrangement of 1 to n, at this moment, I am a little confused. Can you help me solve the problem intelligently?

Enter N (0 <n <10) in the first row, indicating that N groups of test data exist. The next n rows Input Multiple groups of input data, each group of input data is an integer x (0 <x <10)
Output all combinations in a specific order. Specific order: Values in each combination are arranged in ascending order, and the combinations are arranged in lexicographically.
Sample Input
Sample output

 #include <iostream>#include <algorithm>using namespace std;int main(){   int n;   cin>>n;   while(n--)   {       int m;       cin>>m;       int arr[10]={1,2,3,4,5,6,7,8,9,10};       do       {           for(int i =0;i<m;i++)               cout<<arr[i];           cout<<endl;       }while(next_permutation(arr,arr+m));   }    return 0;}        


D's small l

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.