bool trans(int l, int r, strArray &a) { int i = l, ope = 1, j; strArray b, c, d; string s; a.clear(); if (l > r) { a.push_back(""); return 1; }; while (i <= r) { if (st[i] == '+') { if (ope) return 0; ope = 1; ++i; } else { if (!ope || (st[i] < 'a' || st[i] > 'z') && st[i] != '(') return 0; b.clear(); b.push_back(""); while (i <= r && (st[i] >= 'a' && st[i] <= 'z' || st[i] == '(')) { if (st[i] == '(') { if (!findEnd(i, j, r)) return 0; if (!trans(i + 1, j - 1, c)) return 0; i = j + 1; } else { s = ""; while (i <= r && st[i] >= 'a' && st[i] <= 'z') s += st[i ++]; c.clear(); c.push_back(s); }; if (c.empty()) return 0; mult(b, c); }; if (b.size() == 1 && b[0] == "") continue; add(a, b); ope = 0; }; }; if (ope && !a.empty()) return 0; return 1; };