#include <iostream>
using namespace std;
int main(int argc, const char *argv[]) {
int n, capacity = 0, bufsize, target;
cin >> n;
int *terms = new int[n];
for (int i = 0; i < n; i++) cin >> terms[i];
cin >> target;
for (int i = 1; i < n; i++) capacity += terms[i];
bufsize = capacity * 2 + 1;
target += capacity - terms[0];
if (0 <= target && target < bufsize) {
char **dp = new char *[n], *cur = new char[bufsize], *nxt;
fill_n(cur, bufsize, 0);
cur[capacity] = '+';
for (int idx = 1; idx < n; idx++) {
dp[idx] = nxt = new char[bufsize];
fill_n(nxt, bufsize, 0);
int t = terms[idx];
for (int i = t; i < bufsize; i++) {
if (cur[i]) nxt[i - t] = '-';
if (cur[i - t]) nxt[i] = '+';
}
cur = nxt;
}
if (cur[target]) {
char c, *ops = new char[n];
for (int idx = n - 1; idx > 0; idx--) {
ops[idx] = c = dp[idx][target];
target -= c == '+' ? terms[idx] : -terms[idx];
}
cout << terms[0];
for (int idx = 1; idx < n; idx++)
cout << ops[idx] << terms[idx];
return 0;
}
}
cout << "Нет решений";
return 0;
}
SELECT T.*
FROM (SELECT
itemcode,
max(date) AS date
FROM T
WHERE date <= '2017-02-15'
GROUP BY itemcode) AS A
JOIN T USING (itemcode, date);
#include <iostream>
using namespace std;
int main() {
char chars[] = "0123456789!@#$%^&*ABCDE...";
const int sz = sizeof(chars) - 1, n = 5;
// можно просто надёргать случайных букв, но могут быть повторы
srand(time(NULL));
for (int i = 0; i < n; i++) {
cout << chars[rand() % sz];
}
cout << endl;
// а можно перетасовать алфавит - повторов не будет
for (int i = 0; i < sz; i++) {
swap(chars[i], chars[rand() % sz]);
}
for (int i = 0; i < n; i++) {
cout << chars[i];
}
return 0;
}
int DList::ListNodeNumber() {
int counter = 0;
DNode *t = head;
while (t) {
t = t->next;
counter++;
}
return counter;
}