+-*
基本的には、3 つの操作記号 (例:または++/
または)で構成される文字列を作成したいと考えています+++
。これらの文字列はそれぞれにプッシュする必要がありvector <string> opPermutations
ます これまでの私のコードは次のとおりです:
// Set up permutations for operators
string operatorBank[4] = {"+","-","*","/"};
do {
string currentPerm = operatorBank[0] + operatorBank[1] + operatorBank[2] + operatorBank[3];
this -> opPermutations.push_back(currentPerm);
} while ( std::next_permutation(operatorBank, operatorBank + 4) );
ベクトルに (文字列として) プッシュされる順列は次のとおりです。
+-*/
+-/*
+/*-
+/-*
-*+/
-*/+
-+*/
-+/*
-/*+
-/+*
/*+-
/*-+
/+*-
/+-*
/-*+
/-+*
しかし、私が望むのは、私の順列が次のように存在することです:
- それぞれの長さは 3 文字である必要があります
- 文字が複数回繰り返されるものを含め、すべての可能な順列が存在する必要があります。
次のように整理したいと思います。
+++
---
***
///
/*/
+-+
++*
**/
etc...
どうすればこれを達成できますか?