Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
611 B
2
Indexable
Never
#include<iostream>
using namespace std;

void xuat(int *b, int k)
{
    for(int i = 1;i<=k;i++) 
    {
       cout<<b[i];
    }
    cout<<endl;
}


void process(int *a, int n , int i, int k)
{
    int j;
    for(j = a[i-1]+1; j<=n-k+i; j++)
    {
       a[i] = j;
       if(i == k)
       {
           xuat(a,k);
       }
       else process(a,n,i+1,k);
    }
}


int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        int n,k,i;
        cin>>n>>k;
        int a[100];
        for(i = 0;i<=k;i++)
        {
            a[i] = i;
        }
        i = 1;
        process(a,n,i,k);
    }
    return 0;
}