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