Advertisement
AlexandruDu

Generare submultimi

Nov 9th, 2020
1,643
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.57 KB | None | 0 0
  1. tipar
  2. int valid (int k)
  3.    {
  4.      return 1;
  5.                      }
  6. int solutie (int k)
  7.   {
  8.      return (k<=n)
  9.                             }
  10. void bktr() {
  11.     int k = 1;
  12.     st[k] = 0;
  13.     while (k) {
  14.         if (st[k] < n) {
  15.             st[k]++;
  16.             if (valid(k)) {
  17.                 if (sol(k))
  18.                     tipar(k);
  19.                 else {
  20.                     k++;
  21.                     st[k] =st[k-1];
  22.                 }
  23.             }
  24.         }
  25.         else
  26.             k--;
  27.     }
  28. }
  29.  
  30. int main() {
  31.     cin >> n;
  32.     bktr();
  33.     return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement