「 aab + bab = b 」という文字列があるとします。
a
すべての文字を整数 0 に 置き換えます。b
すべての文字を整数 1 に置き換えます
したがって、次のようになります。
001 + 101 = 1
これを行う最も簡単な方法は何ですか?
これまでのところ、方程式を 3 つの部分に分割しました。
System.out.println("Enter an Equation of variables");
_inString = _in.nextLine();
//find the three different parts of the equation
String _noSpaces = _inString.replaceAll("\\s+","");
String delims = "[+,=]";
String[] _tokens = _noSpaces.split(delims);