I enter for example the set 1 2 3 4
Should bring like
2 3 4, 1 3 4, 1 2 4, 1 2 3, 1 2, 1 3, 1 4, 2 3, 2 4, 3 4, 1, 2, 3, 4 So far, it turns out normally to withdraw
2 3 4, 1 3 4, 1 2 4, 1 2 3 What to change / add to display the remaining subsets? And I need a job with recursion.
#include <iostream> using namespace std; int rec(int *mas, int n); int n, m, null; int main () { cout << "n = "; cin >> n; cout << "Array: "; m = n; null = 0; int* mas = new int[n]; for (int i = 0; i < n; i++) { cin >> mas[i]; } rec(mas, n); system("pause"); return 0; } int rec(int *mas, int n) { for (int i = 0; i < n; i++) { if (i != null) { cout << mas[i] << " "; } } cout << endl; null++; m--; if (m == 0) { return 0; } else rec(mas, n); return 0; }