Нужна помощь с задачей по программированию С++ С# Или так или так
Учитывая массив чисел из n целых чисел, верните массив всех уникальных подмассиов.
0 <= a, b, c, d < n
a, b, c, d - > уникальны.
nums[a] + nums[b] + nums[c] + nums[d] == target
Input: nums = [1,0,-1,0,-2,2], target = 0
Output: [[-2,-1,1,2],[-2,0,0,2],[-1,0,0,1]]
Input: nums = [2,2,2,2,2], target = 8
Output: [[2,2,2,2]]
#include <algorithm>
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <numeric>
using namespace std;
int main() {
cout << "target: ";
int target;
cin >> target;
cout << "size: ";
size_t sz;
cin >> sz;
vector<int> box(sz);
cout << "elements: ";
for (auto& x : box) cin >> x;
sort(box.begin(), box.end());
const auto length = 4;
const auto cmp = [target](array<int, length>& cox) {
return accumulate(cox.begin(), cox.end(), 0) == target;
};
const auto an = box.size() - length + 1;
const auto bn = an + 1;
const auto cn = bn + 1;
const auto dn = cn + 1;
set<array<int, length>> fox;
for (auto a = 0U; a < an; ++a) {
for (auto b = a + 1; b < bn; ++b) {
for (auto c = b + 1; c < cn; ++c) {
for (auto d = c + 1; d < dn; ++d) {
array<int, length> cox{ box[a], box[b], box[c], box[d] };
if (cmp(cox)) fox.emplace(cox);
}
}
}
}
cout.put('[');
auto m = 0U;
for (const auto& arr : fox) {
auto n = arr.size();
auto i = 0U;
for (auto x : arr) {
if (!i++) cout.put('[');
cout << x;
if (i != n) cout.put(',');
else cout.put(']');
}
if (++m != fox.size()) cout.put(',');
}
cout.put(']');
system("pause > nul");
}
Учитывая все правила этики, пошлите написавших эту задачу на три уникальных константных символа в русской кодировке.