#include using namespace std; void afisare(int sol[], int lg){ for(int j = 1; j <= lg; ++j) cout << sol[j] << ' '; cout << endl; } void bkt(int s, int n, int i, int sol[]) { for(int j = 1; j <= n; ++j) { sol[i] = j; if(s + j <= n) { if(s + j == n) afisare(sol, i); else bkt(s + j, n, i+ 1, sol); } } } int main() { // se da un numar n natural sa se afiseze toate perechile de numere posibile care insumate dau numarul n (ordinea nu conteaza) int n, s = 0, sol[100]; cin >> n; bkt(s, n, 1, sol); return 0; }