Advertisement
Guest User

Untitled

a guest
Dec 13th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.53 KB | None | 0 0
  1. #include<iostream>
  2. #include<fstream>
  3. using namespace std;
  4. int sol[11],n,k=1, a, b;
  5.  
  6. void init(int k)
  7. {
  8.     sol[k]=a-1;
  9. }
  10. int succesor(int k)
  11. {
  12.     if(sol[k]<b)
  13.     {
  14.         sol[k]++;
  15.         return 1;
  16.     }
  17.     return 0;
  18. }
  19.  
  20. void tipar(int k)
  21. {
  22.     for(int i=1; i<=n; i++)
  23.         cout<<sol[i];
  24.     cout<<endl;
  25. }
  26. void Back(int k)
  27. {
  28.     if(k==n+1)
  29.         tipar(k);
  30.     else
  31.     {
  32.         init(k);
  33.         while(succesor(k))
  34.               Back(k+1);
  35.     }
  36. }
  37. int main()
  38. {
  39.     cin>>a>>b>>n;
  40.     Back(1);
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement