Cod sursa(job #2738362)

Utilizator TocuAndreiTocu Andrei TocuAndrei Data 5 aprilie 2021 19:05:06
Problema Submultimi Scor 0
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.42 kb
#include <iostream>
using namespace std;

int n, qu[20], pos = 1;

void subsets() {
  for (int i = 1; i <= pos; i++ ){
    cout << qu[i] << " ";
  }
  cout << '\n';

  if (pos == 1 && qu[pos] == n) {
    return;
  } else if (pos != 1 &&  qu[pos] == n) {
    qu[pos - 1]++;
    pos--;
    subsets();
  } else {
    pos++;
    qu[pos] = qu[pos - 1] + 1;
    subsets();
  }
}

int main() {
  cin >> n;
  qu[pos] = 1;
  subsets();
}