SHARE
TWEET

5/19 - Cotoc Alexandru

a guest Sep 22nd, 2019 87 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <fstream>
  3.  
  4. using namespace std;
  5. int st[100];
  6. int n;
  7. void init(int k)
  8. {
  9.     st[k]=10;
  10. }
  11. int succesor(int k)
  12. {
  13.     if(st[k]>0)
  14.     {
  15.         st[k]=st[k]-2;
  16.         return 1;
  17.     }
  18.     else
  19.         return 0;
  20. }
  21. int valid(int k)
  22. {
  23.     return 1;
  24. }
  25. int solutie(int k)
  26. {
  27.     return k==n;
  28. }
  29.  void tipar()
  30. {
  31.     int x=0,ki=-1;
  32.     for(int i=1;i<=n;i++)
  33.     {
  34.         if(ki<i && st[i]!=0)
  35.         {
  36.             x=1;
  37.             ki=i;
  38.         }
  39.         if(x==1)
  40.             cout<<st[i];
  41.     }
  42.     cout<<endl;
  43. }
  44. void bkt(int k)
  45. {
  46.     init(k);
  47.     while(succesor(k))
  48.         if(valid(k))
  49.             if(solutie(k))
  50.                 tipar();
  51.             else
  52.                 bkt(k+1);
  53. }
  54. int main()
  55. {
  56.     n=9;
  57.     bkt(1);
  58.     return 0;
  59. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top