Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int x[100],n,m;
- int valid(int k)
- {
- int i;
- for(i=1; i<k; i++)
- if(x[k]<=x[i])
- return 0;
- return 1;
- }
- void afis(int k)
- {
- int i;
- for(i=1; i<=k; i++)
- cout<<x[i]<<" ";
- cout<<endl;
- }
- void BT()
- {
- int k;
- k=1;
- x[k]=0;
- while(k>0)
- if(x[k]<n)
- {
- x[k]=x[k]+1;
- if(valid(k))
- if(k==m)
- afis(k);
- else
- {
- k++;
- x[k]=0;
- }
- }
- else k--;
- }
- int main()
- {
- cin>>n>>m;
- BT();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement